Interface IThrowingUnaryOperator<T>

Type Parameters:
T - the type of the input to the function and output of the function.
All Superinterfaces:
Function<T,T>, IThrowingFunction<T,T>, ITypedThrowingFunction<T, T, Exception>, UnaryOperator<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IThrowingUnaryOperator<T> extends IThrowingFunction<T,T>, UnaryOperator<T>
A UnaryOperator that may throw a checked exception.

Represents a function that accepts one argument and produces a result of the same type.

This is a functional interface whose functional method is IThrowingFunction.apply(Object).

Since:
8.2.0
Author:
XIMA MEDIA GmbH
  • Method Details

    • of

      static <T> IThrowingUnaryOperator<T> of(IThrowingUnaryOperator<T> operator)
      Returns the given operator, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:
      final var fn = IThrowingUnaryOperator.of(t -> ...);
      
      Type Parameters:
      T - The type of the input and output of the operator.
      Parameters:
      operator - Operator to return.
      Returns:
      The given operator.
    • throwingUnaryOperator

      static <T> IThrowingUnaryOperator<T> throwingUnaryOperator(IThrowingUnaryOperator<T> operator)
      Returns the given operator, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:
      final var fn = throwingUnaryOperator(t -> ...);
      
      Type Parameters:
      T - The type of the input and output of the operator.
      Parameters:
      operator - Operator to return.
      Returns:
      The given operator.
    • identity

      static <T> IThrowingUnaryOperator<T> identity()
      Returns a throwing unary operator that always returns its input argument.
      Type Parameters:
      T - The type of the input and output of the operator.
      Returns:
      A throwing unary operator that always returns its input argument.