public final class Functions extends Object
| Modifier and Type | Field and Description |
|---|---|
static Effect0 |
noop
Noop effect.
|
static Effect<Effect0> |
run
Create an effect that runs its argument.
|
| Modifier and Type | Method and Description |
|---|---|
static <A> Effect<A> |
all(Effect<? super A>... es)
Create an effect that runs all given effects in order.
|
static Effect0 |
all(Effect0... es)
Create an effect that runs all given effects in order.
|
static <A,B> Function<List<A>,List<B>> |
bind(Function<A,List<B>> f)
Create a bound version of
f for List. |
static <A,B> Function<Option<A>,Option<B>> |
bindOpt(Function<A,Option<B>> f)
Create a bound version of
f for Option. |
static <A> A |
chuck(Throwable t)
Throw a checked exception like a RuntimeException removing any needs to declare a throws clause.
|
static <A,B> Function<Function<A,? extends B>,Function<A,B>> |
co() |
static <A,B> Function<A,B> |
co(Function<? super A,? extends B> f)
Pure functions are covariant in their result type.
|
static <A> Function<A,A> |
concat(Function<? super A,? extends A>... fs)
Multiple `then` concatenation.
|
static <A,B> Function<A,B> |
constant(B b)
Constant function that always returns
b. |
static <A> Function0<A> |
constant0(A a)
Constant function that always returns
a. |
static <A,B> Function<A,B> |
contra(Function<? super A,B> f)
Pure functions are contravariant in their argument type.
|
static <A,B> Function0<B> |
curry(Function<? super A,? extends B> f,
A a)
Curry a function of arity 1.
|
static <A,B> Function<A,Function0<B>> |
curry(Function<A,B> f)
Curry a function of arity 1.
|
static <A,B,C> Function<A,Function<B,C>> |
curry(Function2<? super A,? super B,? extends C> f)
Curry a function of arity 2.
|
static <A,B,C> Function<B,C> |
curry(Function2<? super A,? super B,? extends C> f,
A a)
Curry a function of arity 2.
|
static <A,B,C> Function<A,Either<C,B>> |
either(Function<? super A,? extends B> f,
Function<? super Exception,? extends C> handler)
Create a new function from
f decorated with an exception handler. |
static <A,B,C> Function2<B,A,C> |
flip(Function2<? super A,? super B,? extends C> f)
Flip arguments of a function of arity 2.
|
static <A,B> com.entwinemedia.fn.Fn<A,B> |
fn(Function<A,B> f)
Create a function from the matterhorn-fn module from a common function.
|
static <A,B> Function<A,B> |
handle(Function<? super A,? extends B> f,
Function<? super Exception,? extends B> handler)
Create a new function from
f decorated with an exception handler. |
static <A> Function<A,A> |
identity()
Identity function.
|
static <A> Function<A,A> |
identity(A example)
Identity function.
|
static <A> Function<A,A> |
identity(Class<A> clazz)
Identity function.
|
static <A,B> Function<A,B> |
ignore(B b)
Constant function that ignores its argument and always returns
a. |
static <A,B,C> Function<A,List<C>> |
kleisliCompList(Function<? super A,List<B>> m,
Function<? super B,List<C>> n)
Kleisli composition of list monads.
|
static <A,B> Function<List<A>,List<B>> |
liftList(Function<A,B> f)
Promote function
a -> b to a List. |
static <A> Function<Option<A>,Option<A>> |
liftOpt(Effect<? super A> f)
Promote effect
a -> () to an Option. |
static <A,B> Function<Option<A>,Option<B>> |
liftOpt(Function<? super A,? extends B> f)
Promote function
a -> b to an Option. |
static <A> Effect<A> |
noop()
Noop effect.
|
static <A,B> Function0<B> |
o(Function<? super A,? extends B> f,
Function0<? extends A> g)
Function composition:
f . |
static <A,B,C> Function<A,C> |
o(Function<? super B,? extends C> f,
Function<? super A,? extends B> g)
Function composition:
f . |
static <A,B,C,D> Function<A,D> |
o(Function<? super C,? extends D> f,
Function<? super B,? extends C> g,
Function<? super A,? extends B> h)
f . |
static <A,B,C,D,E> |
o(Function<? super D,? extends E> f,
Function<? super C,? extends D> g,
Function<? super B,? extends C> h,
Function<? super A,? extends B> i)
f . |
static <A,B> Function<A,B> |
orElse(B zero,
Function<? super A,Option<B>>... fs)
Treat
fs as partial functions. |
static <A,B> Function<A,B> |
rethrow(Function<? super A,? extends B> f,
Function<? super Exception,? extends Exception> transformer)
Create a new function from
f decorated with an exception transformer. |
static <A> Effect<Effect<A>> |
run(A a)
Create an effect that runs its argument passing in
a. |
static <A,B,C> Function<A,C> |
then(Function<? super A,? extends B> f,
Function<? super B,? extends C> g)
Left to right composition:
f then g = g(f(x)) |
static <A,B> Function0<B> |
then(Function0<? extends A> f,
Function<? super A,? extends B> g)
Left to right composition:
f then g = g(f) |
static <A,B> Function0<B> |
then(Function0<? extends A> f,
Function0<? extends B> g)
Apply
f and ignore its result, then apply g. |
static <A,B> Effect<A> |
toEffect(Function<? super A,? extends B> f)
Turn a function into an effect by discarding its result.
|
static <A> Effect0 |
toEffect(Function0<A> f)
Turn a function of arity 0 into an effect by discarding its result.
|
static <A,B,C> Effect2<A,B> |
toEffect(Function2<? super A,? super B,? extends C> f)
Turn a function of arity 2 into an effect by discarding its result.
|
static <A,B> Function<A,Option<B>> |
toFn(Map<? extends A,? extends B> m)
Create a (partial) function from a map.
|
static <A,B> com.google.common.base.Function<A,B> |
toGuava(Function<? super A,? extends B> f)
Convert function
f into a guava function. |
static <A> Predicate<A> |
toPredicate(Function<? super A,Boolean> f) |
static <A,B,C> Function<Tuple<A,B>,C> |
tupled(Function2<? super A,? super B,? extends C> f)
Create a tupled version of a function of arity 2.
|
static <A,B,C> Function2<A,B,C> |
uncurry(Function<? super A,Function<B,C>> f)
Uncurry to a function of arity 2.
|
static <A,B> Function<A,B> |
variant(Function<? super A,? extends B> f)
Pure functions are covariant in their result type and contravariant in their argument type.
|
public static final Effect0 noop
public static <A,B> com.entwinemedia.fn.Fn<A,B> fn(Function<A,B> f)
public static <A,B,C> Function<A,C> o(Function<? super B,? extends C> f, Function<? super A,? extends B> g)
f . g = f(g(x)) = o(f, g)public static <A,B> Function0<B> o(Function<? super A,? extends B> f, Function0<? extends A> g)
f . g = f(g) = o(f, g)public static <A,B,C,D> Function<A,D> o(Function<? super C,? extends D> f, Function<? super B,? extends C> g, Function<? super A,? extends B> h)
f . g . hpublic static <A,B,C,D,E> Function<A,E> o(Function<? super D,? extends E> f, Function<? super C,? extends D> g, Function<? super B,? extends C> h, Function<? super A,? extends B> i)
f . g . h . ipublic static <A> Function<A,A> concat(Function<? super A,? extends A>... fs)
public static <A,B,C> Function<A,C> then(Function<? super A,? extends B> f, Function<? super B,? extends C> g)
f then g = g(f(x))public static <A,B> Function0<B> then(Function0<? extends A> f, Function<? super A,? extends B> g)
f then g = g(f)public static <A,B> Function0<B> then(Function0<? extends A> f, Function0<? extends B> g)
f and ignore its result, then apply g.public static <A,B> Function<A,B> rethrow(Function<? super A,? extends B> f, Function<? super Exception,? extends Exception> transformer)
f decorated with an exception transformer. Any exception that occurs during
application of f is passed to transformer whose return value is then being thrown.public static <A,B> Function<A,B> handle(Function<? super A,? extends B> f, Function<? super Exception,? extends B> handler)
f decorated with an exception handler. Any exception that occurs during
application of f is passed to handler whose return value is then being returned.public static <A,B,C> Function<A,Either<C,B>> either(Function<? super A,? extends B> f, Function<? super Exception,? extends C> handler)
f decorated with an exception handler. The new function either returns the
value of f or in case of an exception being thrown on the application of f the return
value of handler.public static <A,B,C> Function<B,C> curry(Function2<? super A,? super B,? extends C> f, A a)
public static <A,B,C> Function<A,Function<B,C>> curry(Function2<? super A,? super B,? extends C> f)
public static <A,B,C> Function2<A,B,C> uncurry(Function<? super A,Function<B,C>> f)
public static <A,B> Function0<B> curry(Function<? super A,? extends B> f, A a)
public static <A,B> Function<A,Function0<B>> curry(Function<A,B> f)
public static <A,B,C> Function<Tuple<A,B>,C> tupled(Function2<? super A,? super B,? extends C> f)
public static <A,B,C> Function2<B,A,C> flip(Function2<? super A,? super B,? extends C> f)
public static <A> Effect0 toEffect(Function0<A> f)
public static <A,B> Effect<A> toEffect(Function<? super A,? extends B> f)
public static <A,B,C> Effect2<A,B> toEffect(Function2<? super A,? super B,? extends C> f)
public static <A> Effect<A> noop()
public static <A> Function<A,A> identity()
public static <A> Function<A,A> identity(A example)
Function.<Integer>identity() vs. identity(0)
Please note that this constructor is only due to Java's insufficient type inference.public static <A> Function<A,A> identity(Class<A> clazz)
clazz - to describe the functions's typepublic static <A> Function0<A> constant0(A a)
a.public static <A,B> Function<A,B> constant(B b)
b.public static <A,B> Function<A,B> ignore(B b)
a.public static <A,B> Function<Option<A>,Option<B>> liftOpt(Function<? super A,? extends B> f)
a -> b to an Option.public static <A> Function<Option<A>,Option<A>> liftOpt(Effect<? super A> f)
a -> () to an Option.public static <A,B> Function<Option<A>,Option<B>> bindOpt(Function<A,Option<B>> f)
f for Option.public static <A,B> Function<List<A>,List<B>> liftList(Function<A,B> f)
a -> b to a List.public static <A,B> Function<List<A>,List<B>> bind(Function<A,List<B>> f)
f for List.public static <A> Effect<Effect<A>> run(A a)
a.public static <A> Effect<A> all(Effect<? super A>... es)
public static <A,B> Function<A,B> co(Function<? super A,? extends B> f)
public static <A,B> Function<A,B> contra(Function<? super A,B> f)
public static <A,B> Function<A,B> variant(Function<? super A,? extends B> f)
public static <A> A chuck(Throwable t)
public static <A,B,C> Function<A,List<C>> kleisliCompList(Function<? super A,List<B>> m, Function<? super B,List<C>> n)
public static <A,B> com.google.common.base.Function<A,B> toGuava(Function<? super A,? extends B> f)
f into a guava function.public static <A,B> Function<A,Option<B>> toFn(Map<? extends A,? extends B> m)
Copyright © 2009–2020 Opencast Project. All rights reserved.