Functions { @NonNull @SuppressWarnings({"unchecked", "UnusedParameters"}) public static <F> FItem<F, F> functionFrom(@Nullable Class<F> from) { return functionCompiler(); } private  Functions(); @NonNull static Function<F, T> staticFunction(@NonNull final T object); @NonNull static Function<F, T> supplierAsFunction(
      @NonNull final Supplier<? extends T> supplier); @NonNull static Function<T, T> identityFunction(); @NonNull @SuppressWarnings({"unchecked", "UnusedParameters"}) static FItem<F, F> functionFrom(@Nullable Class<F> from); @NonNull @SuppressWarnings({"unchecked", "UnusedParameters"}) static FList<F, List<F>, List<F>> functionFromListOf(
      @Nullable final Class<F> from); @SuppressWarnings("unchecked") @NonNull static Function<Throwable, Result<T>> failedResult(); @SuppressWarnings("unchecked") @NonNull static Function<Result<T>, List<T>> resultAsList(); @SuppressWarnings("unchecked") @NonNull static Function<T, List<T>> itemAsList(); @SuppressWarnings("unchecked") @NonNull static Function<Result<List<T>>, List<T>> resultListAsList();  }
@Test public void shouldCreateFunctionFromItemToItem() { final Function<String, Integer> function = functionFrom(String.class) .apply(new DoubleString()) .thenApply(new StringLength()); assertThat(function.apply(INPUT_STRING), is(10)); }
@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 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')); }
@Test public void shouldCreateFunctionFromItemToListWithThenFilter() { final Function<String, List<Character>> function = functionFrom(String.class) .apply(new DoubleString()) .unpack(new StringToListChar()) .thenFilter(new CharacterFilter('n')); assertThat(function.apply(INPUT_STRING), contains('n', 'n')); }