T
- type of the function input, called domain of the functionR
- type of the function output, called codomain of the functionpublic interface PartialFunction<T,R> extends Function1<T,R>
If the function is not defined for a specific value, apply() may produce an arbitrary result. More specifically it is not guaranteed that the function will throw an exception.
If the function is defined for a specific value, apply() may still throw an exception.
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID
The serial version uid.
|
Modifier and Type | Method and Description |
---|---|
R |
apply(T t)
Applies this function to the given argument and returns the result.
|
static <T,V extends Value<T>> |
getIfDefined()
Factory method for creating a partial function that maps a given
Value to its underlying value. |
boolean |
isDefinedAt(T value)
Tests if a value is contained in the function's domain.
|
default Function1<T,Option<R>> |
lift()
Lifts this partial function into a total function that returns an
Option result. |
static <T,R> PartialFunction<T,R> |
unlift(Function<? super T,? extends Option<? extends R>> totalFunction)
Unlifts a
totalFunction that returns an Option result into a partial function. |
static final long serialVersionUID
static <T,R> PartialFunction<T,R> unlift(Function<? super T,? extends Option<? extends R>> totalFunction)
totalFunction
that returns an Option
result into a partial function.
The total function should be side effect free because it might be invoked twice: when checking if the
unlifted partial function is defined at a value and when applying the partial function to a value.T
- type of the function input, called domain of the functionR
- type of the function output, called codomain of the functiontotalFunction
- the function returning an Option
result.static <T,V extends Value<T>> PartialFunction<V,T> getIfDefined()
Value
to its underlying value.
The partial function is defined for an input Value
if and only if the input Value
is not
empty. If the input Value
is not empty, the partial function will return the underlying value of
the input Value
.T
- type of the underlying value of the input Value
.V
- type of the function input, called domain of the functionValue
to its underlying value.boolean isDefinedAt(T value)
value
- a potential function argumentCopyright © 2019. All Rights Reserved.