| Modifier and Type | Method and Description |
|---|---|
static <A,B,C> Function<C,B> |
ap(Function<C,A> ca,
Function<C,Function<A,B>> cab)
Performs function application within a higher-order function (applicative
functor pattern).
|
static <A,B> Function<Function<A,B>,B> |
apply(A arg)
Function that takes another function and applies it to the argument.
|
static <A,B> Function<Function<A,B>,B> |
apply(Supplier<A> lazyA)
Function that takes another function and applies it to the argument
supplied by the parameter.
|
static <A,B,C> Function<A,C> |
compose(Function<? super B,? extends C> g,
Function<? super A,? extends B> f)
Returns the composition of two functions.
|
static <A,B,C> Function<A,Option<C>> |
composeOption(Function<? super B,? extends Option<? extends C>> bc,
Function<? super A,? extends Option<? extends B>> ab)
Compose two PartialFunctions into one.
|
static <A,B> Function<A,B> |
constant(B constant)
Create a function ignores it's input an produces a constant value
|
static <A,B,C> Function<A,Function<B,C>> |
curried(BiFunction<A,B,C> f2)
Transforms a function that takes 2 arguments into a function that takes the
first argument and return a new function that takes the second argument and
return the final result.
|
static <A,B,C> Function<B,Function<A,C>> |
flip(Function<A,Function<B,C>> f2)
Transforms a function from
A -> (B -> C) into a function from
B -> (A -> C). |
static <F,T> T |
fold(BiFunction<? super T,F,T> f,
T zero,
Iterable<? extends F> elements)
Apply f to each element in elements, with each application using the result
of the previous application as the other argument to f.
|
static <F,S,T extends S> |
fold(Function<Pair<S,F>,T> f,
T zero,
Iterable<? extends F> elements)
Apply f to each element in elements, with each application using the result
of the previous application as the other argument to f.
|
static <A,B> Function<A,Option<B>> |
forMap(Map<A,B> map)
Create a function that performs a map lookup returning None for null
If you do not need a nondefaulted return result using a method reference is
preferred map::get
|
static <A,B> Function<A,B> |
forMapWithDefault(Map<A,B> map,
B defaultValue)
Create a function that performs a map lookup supplying a default value when
a Map#get returns null
If you do not need a defaulted return result using a method reference is
preferred map::get
|
static <D> Function<D,Unit> |
fromConsumer(Consumer<D> consumer)
Get a function (with
Unit return type) that calls the consumer for
all inputs. |
static <A> Function<A,A> |
identity()
Returns the identity function.
|
static <A,B> Function<A,Option<B>> |
isInstanceOf(Class<B> cls)
Partial Function that does a type check and matches if the value is of the
right type.
|
static <A,B> Function<A,Option<B>> |
mapNullToOption(Function<? super A,? extends B> f)
Maps a function that returns nulls into a Partial function that returns an
Option of the result.
|
static <A,B> Function<A,Option<B>> |
matches(Function<? super A,? extends Option<? extends B>> f1,
Function<? super A,? extends Option<? extends B>> f2)
Creates a stack of matcher functions and returns the first result that
matches.
|
static <A,B> Function<A,Option<B>> |
matches(Function<? super A,? extends Option<? extends B>> f1,
Function<? super A,? extends Option<? extends B>> f2,
Function<? super A,? extends Option<? extends B>> f3)
Creates a stack of matcher functions and returns the first result that
matches.
|
static <A,B> Function<A,Option<B>> |
matches(Function<? super A,? extends Option<? extends B>> f1,
Function<? super A,? extends Option<? extends B>> f2,
Function<? super A,? extends Option<? extends B>> f3,
Function<? super A,? extends Option<? extends B>> f4)
Creates a stack of matcher functions and returns the first result that
matches.
|
static <A,B> Function<A,Option<B>> |
matches(Function<? super A,? extends Option<? extends B>> f1,
Function<? super A,? extends Option<? extends B>> f2,
Function<? super A,? extends Option<? extends B>> f3,
Function<? super A,? extends Option<? extends B>> f4,
Function<? super A,? extends Option<? extends B>> f5,
Function<? super A,? extends Option<? extends B>>... fs)
Creates a stack of matcher functions and returns the first result that
matches.
|
static <A> Function<A,Option<A>> |
nullToOption()
Function that turns null inputs into a none, and not-null inputs into some.
|
static <A,B> Function<A,Option<B>> |
partial(Predicate<? super A> p,
Function<? super A,? extends B> f)
|
static <A,B,C> BiFunction<A,B,C> |
toBiFunction(Function<Pair<A,B>,C> fpair)
Converts a function that takes a pair of arguments to a function that takes
two arguments
|
static <A,B> Function<A,B> |
weakMemoize(Function<A,B> f)
Takes a Function and memoizes (caches) the result for each input.
|
public static <A,B,C> Function<A,C> compose(Function<? super B,? extends C> g, Function<? super A,? extends B> f)
f: A->B and
g: B->C, composition is defined as the function h such that
h(a) == g(f(a)) for each a.A - The start typeB - The intermediate typeC - The finished typeg - the second function to apply, must not be nullf - the first function to apply, must not be nullf and gpublic static <A,B,C> Function<C,B> ap(Function<C,A> ca, Function<C,Function<A,B>> cab)
ca - A function to apply within a higher-order function.cab - The higher-order function to apply a function to.public static <F,T> T fold(BiFunction<? super T,F,T> f, T zero, Iterable<? extends F> elements)
F - the element typeT - the final result typef - the function to apply to all the elementszero - the starting point for the functionelements - the series of which each element will be accumulated into a
resultpublic static <F,S,T extends S> T fold(Function<Pair<S,F>,T> f, T zero, Iterable<? extends F> elements)
F - the element typeS - the accumulator function input typeT - the return result typef - the function to apply to all elementszero - the starting point for the functionelements - the series of which each element will be accumulated into a
resultpublic static <A,B> Function<Function<A,B>,B> apply(A arg)
A - the argument and function input typeB - the result typearg - the argument that will be applied to any input functionspublic static <A,B> Function<Function<A,B>,B> apply(Supplier<A> lazyA)
A - the type of the argument supplied, and the function input typeB - the result type of the functionlazyA - the supplier of the argument that will be applied to any input
functionspublic static <A,B> Function<A,Option<B>> isInstanceOf(Class<B> cls)
A - the input typeB - the type we expect it to becls - the type to check against, must not be nullpublic static <A,B> Function<A,Option<B>> partial(Predicate<? super A> p, Function<? super A,? extends B> f)
A - the input typeB - the output typep - the predicate to test the value against, must not be nullf - the function to apply if the predicate passes, must not be nullpublic static <A,B,C> Function<A,Option<C>> composeOption(Function<? super B,? extends Option<? extends C>> bc, Function<? super A,? extends Option<? extends B>> ab)
Kleisli composition. In Haskell it is defined as >=>,
AKA
"compose, fishy, compose"
A - the input typeB - the middle typeC - the output typebc - partial function from B -> C, must not be nullab - partial function from A -> B, must not be nullpublic static <A,B,C> BiFunction<A,B,C> toBiFunction(Function<Pair<A,B>,C> fpair)
A - the type of the left of the pairB - the type of the right of the pairC - the result typefpair - the source function that takes a pair of arguments, must not
be nullpublic static <A,B,C> Function<A,Function<B,C>> curried(BiFunction<A,B,C> f2)
A - the type of the first argumentB - the type of the second argumentC - the type of the final resultf2 - the original function that takes 2 arguments, must not be nullpublic static <A,B,C> Function<B,Function<A,C>> flip(Function<A,Function<B,C>> f2)
A -> (B -> C) into a function from
B -> (A -> C).A - the type of the first argumentB - the type of the second argumentC - the type of the final resultf2 - the original function from A -> (B -> C), must not be
nullpublic static <A,B> Function<A,Option<B>> mapNullToOption(Function<? super A,? extends B> f)
A - the input typeB - the output typef - the function that may return nullspublic static <A> Function<A,Option<A>> nullToOption()
A - the input typepublic static <A,B> Function<A,B> weakMemoize(Function<A,B> f)
NOTE: it is very important that the docs on the input type are read carefully. Failure to heed adhere to this will lead to unspecified behavior (bugs!)
A - the input type, like any cache, this type should be a value,
that is it should be immutable and have correct hashcode and equals
implementations.B - the output typef - the function who's output will be memoized, must not be nullpublic static <D> Function<D,Unit> fromConsumer(Consumer<D> consumer)
Unit return type) that calls the consumer for
all inputs.D - the key typeconsumer - called for all inputs, must not be nullpublic static <A> Function<A,A> identity()
Function.identity()A - a A object.Function that retruns it's input.public static <A,B> Function<A,B> constant(B constant)
A - type of the ignored inputB - type of the constant returnedconstant - value to returnpublic static <A,B> Function<A,Option<B>> forMap(Map<A,B> map)
A - map key typeB - map value typemap - map to use for lookupto supply a default value for nonepublic static <A,B> Function<A,B> forMapWithDefault(Map<A,B> map, B defaultValue)
A - map key typeB - map value typemap - map to use for lookupdefaultValue - a B to use when the map returns null from Map#get.public static <A,B> Function<A,Option<B>> matches(Function<? super A,? extends Option<? extends B>> f1, Function<? super A,? extends Option<? extends B>> f2)
A - the input typeB - the output typef1 - partial function, tried in order.f2 - partial function, tried in order.public static <A,B> Function<A,Option<B>> matches(Function<? super A,? extends Option<? extends B>> f1, Function<? super A,? extends Option<? extends B>> f2, Function<? super A,? extends Option<? extends B>> f3)
A - the input typeB - the output typef1 - partial function, tried in order.f2 - partial function, tried in order.f3 - partial function, tried in order.public static <A,B> Function<A,Option<B>> matches(Function<? super A,? extends Option<? extends B>> f1, Function<? super A,? extends Option<? extends B>> f2, Function<? super A,? extends Option<? extends B>> f3, Function<? super A,? extends Option<? extends B>> f4)
A - the input typeB - the output typef1 - partial function, tried in order.f2 - partial function, tried in order.f3 - partial function, tried in order.f4 - partial function, tried in order.@SafeVarargs public static <A,B> Function<A,Option<B>> matches(Function<? super A,? extends Option<? extends B>> f1, Function<? super A,? extends Option<? extends B>> f2, Function<? super A,? extends Option<? extends B>> f3, Function<? super A,? extends Option<? extends B>> f4, Function<? super A,? extends Option<? extends B>> f5, Function<? super A,? extends Option<? extends B>>... fs)
A - the input typeB - the output typef1 - partial function, tried in order.f2 - partial function, tried in order.f3 - partial function, tried in order.f4 - partial function, tried in order.f5 - partial function, tried in order.fs - partial functions, tried in order.Copyright © 2018 Atlassian. All rights reserved.