Interface IntFunction<R>

Type Parameters:
R - the type of the result of the function
All Superinterfaces:
Function<Integer,​R>, Function<Integer,​R>, IntFunction<R>
All Known Subinterfaces:
IntPredicate, IntToDoubleFunction, IntToLongFunction, IntUnaryOperator
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 IntFunction<R>
extends Function<Integer,​R>, IntFunction<R>
Represents a function that accepts an int-valued argument and produces a result. This is the int-consuming primitive specialization for Function.

This is a functional interface whose functional method is apply(int).

Since:
1.8
See Also:
Function
  • Field Details

  • Method Details

    • apply

      R apply​(int value)
      Applies this function to the given argument.
      Specified by:
      apply in interface IntFunction<R>
      Parameters:
      value - the function argument
      Returns:
      the function result
    • apply

      default R apply​(Integer t)
      Applies this function to the given argument.
      Specified by:
      apply in interface Function<Integer,​R>
      Specified by:
      apply in interface Function<Integer,​R>
      Parameters:
      t - the function argument
      Returns:
      the function result
    • applyPartial

      default Supplier<R> applyPartial​(int t)
      Partially apply a parameter such that a single param function becomes a no-param supplier.
      Parameters:
      t - The parameter to apply.
      Returns:
      A partially-applied function.
    • consume

      default IntConsumer consume​(Consumer<R> consumer)
      Consume a function.
      Specified by:
      consume in interface Function<Integer,​R>
      Parameters:
      consumer - The consumer to use in consuming.
      Returns:
      A Consumer which passes it's argument to this function and then passes the result into the given consumer.
    • mapToPredicate

      default IntPredicate mapToPredicate​(Predicate<? super R> functor)
      Lift a function.
      Specified by:
      mapToPredicate in interface Function<Integer,​R>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • map

      default <S> IntFunction<S> map​(Function<? super R,​? extends S> functor)
      Lift a function.
      Specified by:
      map in interface Function<Integer,​R>
      Type Parameters:
      S - The return type.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToDouble

      default IntToDoubleFunction mapToDouble​(ToDoubleFunction<? super R> functor)
      Lift a function.
      Specified by:
      mapToDouble in interface Function<Integer,​R>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToInt

      default IntUnaryOperator mapToInt​(ToIntFunction<? super R> functor)
      Lift a function.
      Specified by:
      mapToInt in interface Function<Integer,​R>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToLong

      default IntToLongFunction mapToLong​(ToLongFunction<? super R> functor)
      Lift a function.
      Specified by:
      mapToLong in interface Function<Integer,​R>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • identity

      static DoubleUnaryOperator identity()
      Returns a unary operator that always returns its input argument.
      Returns:
      a unary operator that always returns its input argument