Interface GFunctionWithException<T,R>

Type Parameters:
T - Type of argument of the function.
R - Type of result of the function.
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 GFunctionWithException<T,R>
Represents a function that takes one argument and can throw an exception.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(T arg)
    Applies the function.
    static <T, R> R
    applyOrDefault(GFunctionWithException<T,R> function, T arg, R defaultValue)
    Get value from function or default if there is an exception.
    static <T, R> R
    applyOrNull(GFunctionWithException<T,R> function, T arg)
    Get value from function or null if there is an exception.
  • Method Details

    • apply

      R apply(T arg) throws Exception
      Applies the function.
      Parameters:
      arg - Function argument.
      Returns:
      A result.
      Throws:
      Exception - Some exception.
    • applyOrDefault

      static <T, R> R applyOrDefault(GFunctionWithException<T,R> function, T arg, R defaultValue)
      Get value from function or default if there is an exception.
      Type Parameters:
      T - Type of argument.
      R - Type of return value.
      Parameters:
      function - Function.
      arg - Argument for function.
      defaultValue - Default value if there is an exception.
      Returns:
      Value from function or default if there is an exception.
    • applyOrNull

      static <T, R> R applyOrNull(GFunctionWithException<T,R> function, T arg)
      Get value from function or null if there is an exception.
      Type Parameters:
      T - Type of argument.
      R - Type of return value.
      Parameters:
      function - Function.
      arg - Argument for function.
      Returns:
      Value from function or null if there is an exception.