// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
//   return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
//   return functionCompiler();
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
//     @Nullable final Class<F> from) {
//   return functionCompiler();
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
//   @SuppressWarnings("unchecked")
//   final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
//   return identityFunction;
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
//   return new StaticProducer<>(object);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
//     @NonNull final Supplier<? extends T> supplier) {
//   return new SupplierAsFunction<>(supplier);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
//   return (Result<T>) ABSENT;
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
//   return failure == ABSENT_THROWABLE
//       ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
//   return success(value);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
//   return new Result<>(checkNotNull(value), null);
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
//   return INSTANCE;
// }


import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
  @Test
  public void shouldCreateFunctionFromItemToItemViaList() {
    final Function<String, String> function = functionFrom(String.class)
        .apply(new DoubleString())
        .unpack(new StringToListChar())
        .morph(new SortList<Character>())
        .limit(5)
        .filter(new CharacterFilter('n'))
        .thenApply(new CharacterListToString());

    assertThat(function.apply(INPUT_STRING), is("nn"));
  }

  @Test
  public void shouldCreateFunctionFromListToItem() {
    final Function<List<String>, Integer> function = functionFromListOf(String.class)
        .limit(3)
        .map(new StringLength())
        .thenApply(new SumOfIntegersInList());

    assertThat(function.apply(INPUT_LIST), is(14));
  }

  @Test
  public void shouldCreateFunctionFromItemToList() {
    final Function<String, List<Character>> function = functionFrom(String.class)
        .apply(new DoubleString())
        .unpack(new StringToListChar())
        .thenLimit(7);

// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Function<Throwable, Result<T>> failedResult() {
//   return (Function<Throwable, Result<T>>) FAILED_RESULT;
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) {
//   return functionCompiler();
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// @SuppressWarnings({"unchecked", "UnusedParameters"})
// public static <F> FList<F, List<F>, List<F>> functionFromListOf(
//     @Nullable final Class<F> from) {
//   return functionCompiler();
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <T> Function<T, T> identityFunction() {
//   @SuppressWarnings("unchecked")
//   final Function<T, T> identityFunction = (Function<T, T>) NULL_OPERATOR;
//   return identityFunction;
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> staticFunction(@NonNull final T object) {
//   return new StaticProducer<>(object);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Functions.java
// @NonNull
// public static <F, T> Function<F, T> supplierAsFunction(
//     @NonNull final Supplier<? extends T> supplier) {
//   return new SupplierAsFunction<>(supplier);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @SuppressWarnings("unchecked")
// @NonNull
// public static <T> Result<T> absent() {
//   return (Result<T>) ABSENT;
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
//   return failure == ABSENT_THROWABLE
//       ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> present(@NonNull final T value) {
//   return success(value);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
//   return new Result<>(checkNotNull(value), null);
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/HasPrivateConstructor.java
// @NonNull
// @Factory
// public static Matcher<Class<?>> hasPrivateConstructor() {
//   return INSTANCE;
// }


// Path: agera/src/test/java/com/google/android/agera/FunctionsTest.java
import static com.google.android.agera.Functions.failedResult;
import static com.google.android.agera.Functions.functionFrom;
import static com.google.android.agera.Functions.functionFromListOf;
import static com.google.android.agera.Functions.identityFunction;
import static com.google.android.agera.Functions.staticFunction;
import static com.google.android.agera.Functions.supplierAsFunction;
import static com.google.android.agera.Result.absent;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.present;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.HasPrivateConstructor.hasPrivateConstructor;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

  @Test
  public void shouldCreateFunctionFromItemToItemViaList() {
    final Function<String, String> function = functionFrom(String.class)
        .apply(new DoubleString())
        .unpack(new StringToListChar())
        .morph(new SortList<Character>())
        .limit(5)
        .filter(new CharacterFilter('n'))
        .thenApply(new CharacterListToString());

    assertThat(function.apply(INPUT_STRING), is("nn"));
  }

  @Test
  public void shouldCreateFunctionFromListToItem() {
    final Function<List<String>, Integer> function = functionFromListOf(String.class)
        .limit(3)
        .map(new StringLength())
        .thenApply(new SumOfIntegersInList());

    assertThat(function.apply(INPUT_LIST), is(14));
  }

  @Test
  public void shouldCreateFunctionFromItemToList() {
    final Function<String, List<Character>> function = functionFrom(String.class)
        .apply(new DoubleString())
        .unpack(new StringToListChar())
        .thenLimit(7);

    assertThat(function.apply(INPUT_STRING), contains('i', 'n', 'p', 'u', 't', 'i', 'n'));