Interface Function<T,R>

Type Parameters:
T - the function parameter type
R - the function return type
All Superinterfaces:
Function<T,R>
All Known Subinterfaces:
UnaryOperator<T>
All Known Implementing Classes:
Function.IdentityFunction, SessionAttributeActivationNotifierFactory, UnaryOperator.IdentityOperator

public interface Function<T,R> extends Function<T,R>
An enhanced function.
Author:
Paul Ferraro
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Function<?,?>
     
    static final Function<?,?>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default <V> Function<T,V>
    andThen(Function<? super R,? extends V> after)
     
    default <V> Function<V,R>
    compose(Function<? super V,? extends T> before)
     
    static <T extends R, R>
    Function<T,R>
    Returns a function that returns its parameter.
    static <T, R> Function<T,R>
    of(Supplier<R> supplier)
    Returns a function that returns the value returned by the specified supplier, ignoring its parameter.
    static <T, R> Function<T,R>
    of(R result)
    Returns a function that always returns the specified value, ignoring its parameter.
    default Function<T,R>
    orDefault(Predicate<T> predicate, Supplier<R> defaultResult)
    Returns a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
    default Function<T,R>
    withDefault(Predicate<T> predicate, Supplier<T> defaultValue)
    Returns a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.

    Methods inherited from interface java.util.function.Function

    apply
  • Field Details

    • IDENTITY

      static final Function<?,?> IDENTITY
    • NULL

      static final Function<?,?> NULL
  • Method Details

    • compose

      default <V> Function<V,R> compose(Function<? super V,? extends T> before)
      Specified by:
      compose in interface Function<T,R>
    • andThen

      default <V> Function<T,V> andThen(Function<? super R,? extends V> after)
      Specified by:
      andThen in interface Function<T,R>
    • withDefault

      default Function<T,R> withDefault(Predicate<T> predicate, Supplier<T> defaultValue)
      Returns a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.
      Parameters:
      predicate - a predicate used to determine the parameter of this function
      defaultValue - a provider of the default parameter value
      Returns:
      a function that applies this function to the value returned by the specified provider if its value does not match the specified predicate.
    • orDefault

      default Function<T,R> orDefault(Predicate<T> predicate, Supplier<R> defaultResult)
      Returns a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
      Parameters:
      predicate - a predicate used to determine the parameter of this function
      defaultResult - a provider of the default parameter value
      Returns:
      a function that applies this function if its parameter matches the specified predicate, or returns the value provided by the specified supplier otherwise.
    • identity

      static <T extends R, R> Function<T,R> identity()
      Returns a function that returns its parameter.
      Type Parameters:
      T - the function parameter type
      R - the function return type
      Returns:
      an identity function
    • of

      static <T, R> Function<T,R> of(R result)
      Returns a function that always returns the specified value, ignoring its parameter.
      Type Parameters:
      T - the function parameter type
      R - the function return type
      Parameters:
      result - the function result
      Returns:
      a function that always returns the specified value, ignoring its parameter.
    • of

      static <T, R> Function<T,R> of(Supplier<R> supplier)
      Returns a function that returns the value returned by the specified supplier, ignoring its parameter.
      Type Parameters:
      T - the function parameter type
      R - the function return type
      Parameters:
      supplier - the function result supplier
      Returns:
      a function that returns the value returned by the specified supplier, ignoring its parameter.