Interface ThrowingUnaryOperation<T>

  • Type Parameters:
    T - the type of the input to the function
    All Superinterfaces:
    ThrowingFunction<T,​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 ThrowingUnaryOperation<T>
    extends ThrowingFunction<T,​T>
    Represents an operation on a single operand that produces a result of the same type as its operand. This is a specialization of Function for the case where the operand and result are of the same type.

    When you find yourself in a situation where you need to use a function ( that throws an exception), this class is what you need to achieve your goal without Java complaining.

    The class Represents a function that accepts one argument and produces a result. whose functional method is ThrowingFunction.apply(Object).

    Since:
    1.0
    Author:
    , Bobai Kato
    See Also:
    ThrowingFunction, UnaryOperator
    • Method Detail

      • identity

        @Contract(pure=true)
        @NotNull
        static <T> @NotNull UnaryOperator<T> identity()
        Returns a unary operator that always returns its input argument.
        Type Parameters:
        T - the type of the input and output of the operator
        Returns:
        a unary operator that always returns its input argument
      • unchecked

        @Contract(pure=true)
        @NotNull
        static <T> @NotNull UnaryOperator<T> unchecked​(ThrowingUnaryOperation<T> operator)
        Uncheck method which will take operation that will throw Exception.
        Type Parameters:
        T - the type of the input to the function
        Parameters:
        operator - Variable of ThrowingFunction
        Returns:
        A Function
      • sneakyThrow

        @Contract(value="_ -> fail",
                  pure=true)
        static <T extends Exception,​R> R sneakyThrow​(Exception ex)
                                                    throws T extends Exception
        Sneak exception on function execution.
        Type Parameters:
        T - arg type
        R - return type
        Parameters:
        ex - exception throw on operation
        Returns:
        an exception
        Throws:
        T - arg type exception
        T extends Exception