Package zone.lamprey.function
Interface Function<T,R>
- Type Parameters:
T- the type of the input to the functionR- the type of the result of the function
- All Superinterfaces:
Function<T,R>
- All Known Subinterfaces:
DoubleFunction<R>,DoublePredicate,DoubleToIntFunction,DoubleToLongFunction,DoubleUnaryOperator,IntFunction<R>,IntPredicate,IntToDoubleFunction,IntToLongFunction,IntUnaryOperator,LongFunction<R>,LongPredicate,LongToDoubleFunction,LongToIntFunction,LongUnaryOperator,Predicate<T>,ToDoubleFunction<T>,ToIntFunction<T>,ToLongFunction<T>,UnaryOperator<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Function<T,R> extends Function<T,R>
Represents a function that accepts one argument and produces a result.
This is a functional interface whose
functional method is apply(Object).
- Since:
- 1.8
-
Field Summary
Fields Modifier and Type Field Description static Function<?,String>TO_STRINGFunctional interface toObjects.toString(java.lang.Object) -
Method Summary
Modifier and Type Method Description Rapply(T t)Applies this function to the given argument.default Supplier<? extends R>applyPartial(T t)Partially apply a parameter such that a single param function becomes a no-param supplier.default Consumer<T>consume(Consumer<R> consumer)Consume a function.static <T> Function<T,T>identity()Returns a function that always returns its input argument.default <S> Function<T,S>map(Function<? super R,? extends S> functor)Lift a function.default ToDoubleFunction<T>mapToDouble(ToDoubleFunction<? super R> functor)Lift a function.default ToIntFunction<T>mapToInt(ToIntFunction<? super R> functor)Lift a function.default ToLongFunction<T>mapToLong(ToLongFunction<? super R> functor)Lift a function.default Predicate<T>mapToPredicate(Predicate<? super R> functor)Lift a function.
-
Field Details
-
TO_STRING
Functional interface toObjects.toString(java.lang.Object)
-
-
Method Details
-
apply
Applies this function to the given argument. -
applyPartial
Partially apply a parameter such that a single param function becomes a no-param supplier.- Parameters:
t- The parameter to apply.- Returns:
- A partially-applied function.
-
consume
Consume a function.- Parameters:
consumer- The consumer to use in consuming.- Returns:
- A Consumer which passes it's argument to this function and then passes the result into the given consumer.
-
map
Lift a function.- Type Parameters:
S- The return type.- Parameters:
functor- The function to use in lifting.- Returns:
- A function that passes the result of fn through a functor to produce a lifted function.
-
mapToPredicate
Lift a function.- Parameters:
functor- The function to use in lifting.- Returns:
- A function that passes the result of fn through a functor to produce a lifted function.
-
mapToDouble
Lift a function.- Parameters:
functor- The function to use in lifting.- Returns:
- A function that passes the result of fn through a functor to produce a lifted function.
-
mapToInt
Lift a function.- Parameters:
functor- The function to use in lifting.- Returns:
- A function that passes the result of fn through a functor to produce a lifted function.
-
mapToLong
Lift a function.- Parameters:
functor- The function to use in lifting.- Returns:
- A function that passes the result of fn through a functor to produce a lifted function.
-
identity
Returns a function that always returns its input argument.- Type Parameters:
T- the type of the input and output objects to the function- Returns:
- a function that always returns its input argument
-