/**
 * Copyright 2013 Cloudera Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kitesdk.data.crunch;

import java.net.URI;
import com.google.common.annotations.Beta;
import org.apache.crunch.Target;
import org.apache.crunch.io.ReadableSource;
import org.kitesdk.data.Dataset;
import org.kitesdk.data.View;

/**
 * <p>
 * A helper class for exposing {@link Dataset}s and {@link View}s as Crunch
 * {@link ReadableSource}s or {@link Target}s.
 * </p>
 */
@Beta
public class CrunchDatasets {

  /**
   * Expose the given {@link Dataset} as a Crunch {@link ReadableSource}.
   *
   * @param dataset the dataset to read from
   * @param type    the Java type of the entities in the dataset
   * @param <E>     the type of entity produced by the source
   * @return a {@link ReadableSource} for the dataset
   * @deprecated will be removed in 0.16.0; use {@link #asSource(View, Class)}
   */
  @Deprecated
  public static <E> ReadableSource<E> asSource(Dataset<E> dataset, Class<E> type) {
    return new DatasetSourceTarget<E>(dataset, type);
  }

  /**
   * Expose the given {@link View} as a Crunch {@link ReadableSource}.
   *
   * @param view the view to read from
   * @param type    the Java type of the entities in the dataset
   * @param <E>     the type of entity produced by the source
   * @return a {@link ReadableSource} for the view
   *
   * @since 0.14.0
   */
  public static <E> ReadableSource<E> asSource(View<E> view, Class<E> type) {
    return new DatasetSourceTarget<E>(view, type);
  }
  
  
  /**
   * Expose the {@link View} or {@link Dataset} represented by the URI
   * as a Crunch {@link ReadableSource}.
   *
   * @param view the URI of the view or dataset to read from
   * @param type    the Java type of the entities in the dataset
   * @param <E>     the type of entity produced by the source
   * @return a {@link ReadableSource} for the view
   */
  public static <E> ReadableSource<E> asSource(URI uri, Class<E> type) {
    return new DatasetSourceTarget<E>(uri, type);
  }
  
  /**
   * Expose the {@link View} or {@link Dataset} represented by the URI
   * as a Crunch {@link ReadableSource}.
   *
   * @param view the URI of the view or dataset to read from
   * @param type    the Java type of the entities in the dataset
   * @param <E>     the type of entity produced by the source
   * @return a {@link ReadableSource} for the view
   */
  public static <E> ReadableSource<E> asSource(String uri, Class<E> type) {
    return asSource(URI.create(uri), type);
  }

  /**
   * Expose the given {@link Dataset} as a Crunch {@link Target}.
   *
   * @param dataset the dataset to write to
   * @param <E>     the type of entity stored in the dataset
   * @return a {@link Target} for the dataset
   * @deprecated will be removed in 0.16.0; use {@link #asTarget(View)}
   */
  @Deprecated
  public static <E> Target asTarget(Dataset<E> dataset) {
    return new DatasetTarget<E>(dataset);
  }

  /**
   * Expose the given {@link View} as a Crunch {@link Target}.
   *
   * @param view the view to write to
   * @param <E>  the type of entity stored in the view
   * @return a {@link Target} for the view
   *
   * @since 0.14.0
   */
  public static <E> Target asTarget(View<E> view) {
    return new DatasetTarget<E>(view);
  }

  /**
   * Expose the {@link Dataset} or {@link View} represented by the given
   * URI as a Crunch {@link Target}.
   * 
   * @param uri the dataset or view URI
   * @return a {@link Target} for the dataset or view
   */
  public static Target asTarget(String uri) {
    return asTarget(URI.create(uri));
  }
  
  /**
   * Expose the {@link Dataset} or {@link View} represented by the given
   * URI as a Crunch {@link Target}.
   * 
   * @param uri the dataset or view URI
   * @return a {@link Target} for the dataset or view
   */
  public static Target asTarget(URI uri) {
    return new DatasetTarget<Object>(uri);
  }
}

@@ -2024,21 +2024,17 @@
 e);%0A  %7D%0A
-  %0A  
+%0A
 %0A  /**%0A 
@@ -2153,36 +2153,35 @@
   *%0A   * @param 
-view
+uri
  the URI of the 
@@ -2516,26 +2516,24 @@
  type);%0A  %7D%0A
-  
 %0A  /**%0A   * 
@@ -2652,28 +2652,27 @@
    * @param 
-view
+uri
  the URI of 
@@ -3886,33 +3886,32 @@
 nk Target%7D.%0A   *
- 
 %0A   * @param uri
@@ -4083,18 +4083,16 @@
 ));%0A  %7D%0A
-  
 %0A  /**%0A 
@@ -4204,17 +4204,16 @@
 t%7D.%0A   *
- 
 %0A   * @p

Fix @param tags in CrunchDatasets