Interface UnaryOperator<T>

Type Parameters:
T - the operating type
All Superinterfaces:
Function<T,T>, Function<T,T>, UnaryOperator<T>

public interface UnaryOperator<T> extends UnaryOperator<T>, Function<T,T>
An enhanced unary operator.
Author:
Paul Ferraro
  • Field Details

    • IDENTITY

      static final UnaryOperator<?> IDENTITY
      An identity operator that always returns its parameter
    • NULL

      static final UnaryOperator<?> NULL
      An operator that always returns null
  • Method Details

    • orDefault

      default UnaryOperator<T> orDefault(Predicate<T> predicate, Supplier<T> defaultResult)
      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:
      orDefault in interface Function<T,T>
      Parameters:
      predicate - a predicate used to determine the parameter of this function
      defaultResult - 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

      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.
      Specified by:
      withDefault in interface Function<T,T>
      Parameters:
      predicate - a predicate used to determine the parameter of this function
      defaultValue - 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

      default UnaryOperator<T> andThen(UnaryOperator<T> operator)
      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

      default UnaryOperator<T> compose(UnaryOperator<T> operator)
      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

      default UnaryOperator<T> handle(BiFunction<T, RuntimeException, T> handler)
      Returns a new operator that delegates to this operator using the specified exception handler.
      Specified by:
      handle in interface Function<T,T>
      Parameters:
      handler - an exception handler
      Returns:
      a new operator that delegates to this operator using the specified exception handler.
    • identity

      static <T> UnaryOperator<T> identity()
      Returns an operator that returns its value.
      Type Parameters:
      T - the operating type
      Returns:
      an operator that returns its value.
    • empty

      static <T> UnaryOperator<T> 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

      static <T> UnaryOperator<T> of(T value)
      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

      static <T> UnaryOperator<T> of(Consumer<T> consumer, Supplier<T> supplier)
      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 parameter
      supplier - 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

      static <T> UnaryOperator<T> apply(Function<? super T, T> function)
      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 a Map.Entry function from the specified key and value functions.
      Type Parameters:
      K - the entry key type
      V - the entry value type
      Parameters:
      keyFunction - an entry key function
      valueFunction - an entry value function
      Returns:
      a Map.Entry function from the specified key and value functions.