Interface UnaryOperator<T>
- Type Parameters:
T- the operating type
- All Superinterfaces:
Function<T,T>, Function<T, T>, UnaryOperator<T>
An enhanced unary operator.
- Author:
- Paul Ferraro
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UnaryOperator<?> An identity operator that always returns its parameterstatic final UnaryOperator<?> An operator that always returns null -
Method Summary
Modifier and TypeMethodDescriptiondefault UnaryOperator<T> andThen(UnaryOperator<T> operator) Returns an operator that applies the specified operator to the result of this operator.static <T> UnaryOperator<T> Returns an operator view of the specified function.default UnaryOperator<T> compose(UnaryOperator<T> operator) Returns an operator that applies this operator to the result of the specified operator.static <T> UnaryOperator<T> empty()Returns an operator that always returns null, ignoring its parameter.static <K,V> UnaryOperator <Map.Entry<K, V>> entry(UnaryOperator<K> keyFunction, UnaryOperator<V> valueFunction) Returns aMap.Entryfunction from the specified key and value functions.default UnaryOperator<T> handle(BiFunction<T, RuntimeException, T> handler) Returns a new operator that delegates to this operator using the specified exception handler.static <T> UnaryOperator<T> identity()Returns an operator that returns its value.static <T> UnaryOperator<T> Returns an operator that accepts its parameter via the specified consumer and returns the value returned by the specified supplier.static <T> UnaryOperator<T> of(T value) Returns an operator that always returns the specified value, ignoring its parameter.default UnaryOperator<T> Returns an operator that applies this function to the value returned by the specified provider if its value does not match the specified predicate.default UnaryOperator<T> withDefault(Predicate<T> predicate, Supplier<T> defaultValue) Returns an operator that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
-
Field Details
-
IDENTITY
An identity operator that always returns its parameter -
NULL
An operator that always returns null
-
-
Method Details
-
orDefault
Returns an operator that applies this function to the value returned by the specified provider if its value does not match the specified predicate.- Specified by:
orDefaultin interfaceFunction<T,T> - Parameters:
predicate- a predicate used to determine the parameter of this functiondefaultResult- a provider of the default operation result- Returns:
- an operator that applies this function to the value returned by the specified provider if its value does not match the specified predicate.
-
withDefault
Returns an operator that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.- Specified by:
withDefaultin interfaceFunction<T,T> - Parameters:
predicate- a predicate used to determine the parameter of this functiondefaultValue- a provider of the default parameter value- Returns:
- an operator that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
-
andThen
Returns an operator that applies the specified operator to the result of this operator.- Parameters:
operator- an operator to apply to the result of this operation- Returns:
- an operator that applies the specified operator to the result of this operator.
-
compose
Returns an operator that applies this operator to the result of the specified operator.- Parameters:
operator- an operator to apply to the result of this operation- Returns:
- an operator that applies this operator to the result of the specified operator.
-
handle
Returns a new operator that delegates to this operator using the specified exception handler. -
identity
Returns an operator that returns its value.- Type Parameters:
T- the operating type- Returns:
- an operator that returns its value.
-
empty
Returns an operator that always returns null, ignoring its parameter.- Type Parameters:
T- the operating type- Returns:
- an operator that always returns null, ignoring its parameter.
-
of
Returns an operator that always returns the specified value, ignoring its parameter.- Type Parameters:
T- the operating type- Parameters:
value- the value returned by the operator- Returns:
- an operator that always returns the specified value, ignoring its parameter.
-
of
Returns an operator that accepts its parameter via the specified consumer and returns the value returned by the specified supplier.- Type Parameters:
T- the operator type- Parameters:
consumer- a consumer of the operator parametersupplier- the supplier of the operator result- Returns:
- an operator that accepts its parameter via the specified consumer and returns the value returned by the specified supplier.
-
apply
Returns an operator view of the specified function.- Type Parameters:
T- the operating type- Parameters:
function- the delegating function- Returns:
- an operator view of the specified function.
-
entry
static <K,V> UnaryOperator<Map.Entry<K,V>> entry(UnaryOperator<K> keyFunction, UnaryOperator<V> valueFunction) Returns aMap.Entryfunction from the specified key and value functions.- Type Parameters:
K- the entry key typeV- the entry value type- Parameters:
keyFunction- an entry key functionvalueFunction- an entry value function- Returns:
- a
Map.Entryfunction from the specified key and value functions.
-