public abstract static class Lang.F1<P1,R> extends Lang.FuncBase implements Lang.Func1<P1,R>, Lang.Bijection<P1,R>, Lang.MultiplicableFunction<P1,R>
Base implementation of Lang.Function function. User application should (nearly) always make their implementation extend to this base class instead of implement Lang.Function directly
| Constructor and Description |
|---|
F1() |
| Modifier and Type | Method and Description |
|---|---|
Lang.F1<P1,R> |
andThen(Lang.Function<? super P1,? extends R>... afters)
Returns a composed function that applied, in sequence, this function and all functions specified one by one.
|
<T> Lang.F1<P1,T> |
andThen(Lang.Function<? super R,? extends T> after)
Returns a composed function that applies this function to it’s input and then applies the
after function to the result. |
R |
applyOrElse(P1 p1,
Lang.F1<? super P1,? extends R> fallback)
Applies this partial function to the given argument when it is contained in the function domain.
|
Lang.F0<R> |
compose(Lang.Func0<? extends P1> before)
Returns an
F0<R>> function by composing the specified Func0<P1> function with this function applied last |
<X1,X2> Lang.F2<X1,X2,R> |
compose(Lang.Func2<? super X1,? super X2,? extends P1> before)
Returns an
F2<X1, X2, R>> function by composing the specified Func2<X1, X2, P1> function with this function applied last |
<X1,X2,X3> Lang.F3<X1,X2,X3,R> |
compose(Lang.Func3<? super X1,? super X2,? super X3,? extends P1> before)
Returns an
F3<X1, X2, X3, R>> function by composing the specified Func3<X1, X2, X3, P1> function with this function applied last |
<X1,X2,X3,X4> |
compose(Lang.Func4<? super X1,? super X2,? super X3,? super X4,? extends P1> before)
Returns an
F3<X1, X2, X3, X4, R>> function by composing the specified Func3<X1, X2, X3, X4, P1> function with this function applied last |
<X1,X2,X3,X4,X5> |
compose(Lang.Func5<? super X1,? super X2,? super X3,? super X4,? super X5,? extends P1> before)
Returns an
F3<X1, X2, X3, X4, X5, R>> function by composing the specified Func3<X1, X2, X3, X4, X5, P1> function with this function applied last |
<X1> Lang.F1<X1,R> |
compose(Lang.Function<? super X1,? extends P1> before)
Returns an
F1<X1, R>> function by composing the specified Function<X1, P1> function with this function applied last |
Lang.F0<R> |
curry(P1 p1) |
Lang.Bijection<R,P1> |
invert()
Returns the inverse function mapping from
Y back to X |
Lang.F1<P1,Lang.Option<R>> |
lift()
Turns this partial function into a plain function returning an Option result.
|
Lang.F1<P1,R> |
orElse(Lang.Function<? super P1,? extends R> fallback)
Returns a composed function that when applied, try to apply this function first, in case a
NotAppliedException is captured apply to the fallback function specified. |
Lang.MultiplicableFunction<P1,R> |
times(int n)
Returns a function with
n times factor specified. |
breakOutclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplypublic Lang.Bijection<R,P1> invert()
Lang.BijectionReturns the inverse function mapping from Y back to X
invert in interface Lang.Bijection<P1,R>Y type element to X type elementpublic Lang.MultiplicableFunction<P1,R> times(int n)
Lang.MultiplicableFunctionReturns a function with n times factor specified. When the function returned applied to a param, the effect is the same as apply this function n times to the same param
times in interface Lang.MultiplicableFunction<P1,R>n - specify the times factorpublic R applyOrElse(P1 p1, Lang.F1<? super P1,? extends R> fallback)
Applies this partial function to the given argument when it is contained in the function domain. Applies fallback function where this partial function is not defined.
p1 - the argument this function to be appliedfallback - the function to be applied to the argument p1 when this function failed with any runtime exceptionpublic <T> Lang.F1<P1,T> andThen(Lang.Function<? super R,? extends T> after)
Returns a composed function that applies this function to it’s input and then applies the after function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.
T - the type of return value of the new composed functionafter - the function applies after this function is appliedNullPointerException - if @{code after} is nullpublic Lang.F1<P1,R> andThen(Lang.Function<? super P1,? extends R>... afters)
Returns a composed function that applied, in sequence, this function and all functions specified one by one. If applying anyone of the functions throws an exception, it is relayed to the caller of the composed function. If an exception is thrown out, the following functions will not be applied.
When apply the composed function, the result of the last function is returned
afters - a sequence of function to be applied after this functionpublic Lang.F1<P1,R> orElse(Lang.Function<? super P1,? extends R> fallback)
Returns a composed function that when applied, try to apply this function first, in case a NotAppliedException is captured apply to the fallback function specified. This method helps to implement partial function
fallback - the function to applied if this function doesn’t apply to the parameter(s)public Lang.F0<R> compose(Lang.Func0<? extends P1> before)
Returns an F0<R>> function by composing the specified Func0<P1> function with this function applied last
before - the function to be applied first when applying the return functionpublic <X1> Lang.F1<X1,R> compose(Lang.Function<? super X1,? extends P1> before)
Returns an F1<X1, R>> function by composing the specified Function<X1, P1> function with this function applied last
X1 - type of argument takes by the before functionbefore - the function to be applied first when applying the return functionpublic <X1,X2> Lang.F2<X1,X2,R> compose(Lang.Func2<? super X1,? super X2,? extends P1> before)
Returns an F2<X1, X2, R>> function by composing the specified Func2<X1, X2, P1> function with this function applied last
X1 - the type of first param the new function applied toX2 - the type of second param the new function applied tobefore - the function to be applied first when applying the return functionpublic <X1,X2,X3> Lang.F3<X1,X2,X3,R> compose(Lang.Func3<? super X1,? super X2,? super X3,? extends P1> before)
Returns an F3<X1, X2, X3, R>> function by composing the specified Func3<X1, X2, X3, P1> function with this function applied last
X1 - the type of first param the new function applied toX2 - the type of second param the new function applied toX3 - the type of third param the new function applied tobefore - the function to be applied first when applying the return functionpublic <X1,X2,X3,X4> Lang.F4<X1,X2,X3,X4,R> compose(Lang.Func4<? super X1,? super X2,? super X3,? super X4,? extends P1> before)
Returns an F3<X1, X2, X3, X4, R>> function by composing the specified Func3<X1, X2, X3, X4, P1> function with this function applied last
X1 - the type of first param the new function applied toX2 - the type of second param the new function applied toX3 - the type of third param the new function applied toX4 - the type of fourth param the new function applied tobefore - the function to be applied first when applying the return functionpublic <X1,X2,X3,X4,X5> Lang.F5<X1,X2,X3,X4,X5,R> compose(Lang.Func5<? super X1,? super X2,? super X3,? super X4,? super X5,? extends P1> before)
Returns an F3<X1, X2, X3, X4, X5, R>> function by composing the specified Func3<X1, X2, X3, X4, X5, P1> function with this function applied last
X1 - the type of first param the new function applied toX2 - the type of second param the new function applied toX3 - the type of third param the new function applied toX4 - the type of fourth param the new function applied toX5 - the type of fifth param the new function applied tobefore - the function to be applied first when applying the return functionpublic Lang.F1<P1,Lang.Option<R>> lift()
Turns this partial function into a plain function returning an Option result.
Copyright © 2014–2021 OSGL (Open Source General Library). All rights reserved.