Class Functions
java.lang.Object
org.opencastproject.util.data.functions.Functions
General purpose functions, especially function transformations.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <A> AThrow a checked exception like a RuntimeException removing any needs to declare a throws clause.static <A,B> Function <A, B> Pure functions are covariant in their result type.static <A,B> Function <A, B> Pure functions are contravariant in their argument type.static <A,B> Function0 <B> Curry a function of arity 1.Curry a function of arity 1.Curry a function of arity 2.static <A,B, C> Function <B, C> Curry a function of arity 2.Create a new function fromfdecorated with an exception handler.static <A,B, C> Function2 <B, A, C> Flip arguments of a function of arity 2.static <A,B> Function <A, B> Create a new function fromfdecorated 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 function.static <A,B> Function0 <B> Function composition:f . g = f(g) = o(f, g)static <A,B, C> Function <A, C> Function composition:f . g = f(g(x)) = o(f, g)static <A,B> Function <A, B> rethrow(Function<? super A, ? extends B> f, Function<? super Exception, ? extends Exception> transformer) Create a new function fromfdecorated with an exception transformer.static <A,B, C> Function <A, C> Left to right composition:f then g = g(f(x))static <A,B> Function0 <B> Left to right composition:f then g = g(f)static <A,B> Function0 <B> Applyfand ignore its result, then applyg.static <A,B> Effect <A> Turn a function into an effect by discarding its result.static <A,B> com.google.common.base.Function <A, B> Convert functionfinto a guava function.static <A> Predicate<A> toPredicate(Function<? super A, Boolean> f) static <A,B, C> Function2 <A, B, C> Uncurry to a function of arity 2. a -gt; b -gt; c =gt; (a, b) -gt; cstatic <A,B> Function <A, B> Pure functions are covariant in their result type and contravariant in their argument type.
-
Field Details
-
noop
Noop effect. -
run
Create an effect that runs its argument.
-
-
Method Details
-
o
public static <A,B, Function<A,C> C> o(Function<? super B, ? extends C> f, Function<? super A, ? extends B> g) Function composition:f . g = f(g(x)) = o(f, g) -
o
Function composition:f . g = f(g) = o(f, g) -
then
public static <A,B, Function<A,C> C> then(Function<? super A, ? extends B> f, Function<? super B, ? extends C> g) Left to right composition:f then g = g(f(x)) -
then
Left to right composition:f then g = g(f) -
then
Applyfand ignore its result, then applyg. -
rethrow
public static <A,B> Function<A,B> rethrow(Function<? super A, ? extends B> f, Function<? super Exception, ? extends Exception> transformer) Create a new function fromfdecorated with an exception transformer. Any exception that occurs during application offis passed totransformerwhose return value is then being thrown. -
handle
public static <A,B> Function<A,B> handle(Function<? super A, ? extends B> f, Function<? super Exception, ? extends B> handler) Create a new function fromfdecorated with an exception handler. Any exception that occurs during application offis passed tohandlerwhose return value is then being returned. -
either
public static <A,B, Function<A,C> Either<C, eitherB>> (Function<? super A, ? extends B> f, Function<? super Exception, ? extends C> handler) Create a new function fromfdecorated with an exception handler. The new function either returns the value offor in case of an exception being thrown on the application offthe return value ofhandler. -
curry
Curry a function of arity 2. -
curry
public static <A,B, Function<A,C> Function<B, curryC>> (Function2<? super A, ? super B, ? extends C> f) Curry a function of arity 2. (a, b) -gt; c =gt; a -gt; b -gt; c -
uncurry
Uncurry to a function of arity 2. a -gt; b -gt; c =gt; (a, b) -gt; c -
curry
Curry a function of arity 1. -
curry
Curry a function of arity 1. -
flip
Flip arguments of a function of arity 2. -
toEffect
Turn a function into an effect by discarding its result. -
toPredicate
-
identity
Identity function. -
identity
Identity function. The type is based on the type of the example object to save some nasty typing, e.g.Function.<Integer>identity()vs.identity(0)Please note that this constructor is only due to Java's insufficient type inference. -
identity
Identity function.- Parameters:
clazz- to describe the functions's type
-
co
Pure functions are covariant in their result type. -
contra
Pure functions are contravariant in their argument type. -
variant
Pure functions are covariant in their result type and contravariant in their argument type. -
chuck
Throw a checked exception like a RuntimeException removing any needs to declare a throws clause. This technique has been described by James Iry at http://james-iry.blogspot.de/2010/08/on-removing-java-checked-exceptions-by.html -
toGuava
public static <A,B> com.google.common.base.Function<A,B> toGuava(Function<? super A, ? extends B> f) Convert functionfinto a guava function.
-