Skip to content

Instantly share code, notes, and snippets.

@ddimtirov
Created December 1, 2016 05:08
Show Gist options
  • Save ddimtirov/2c656155850d4c641201e0a905e25f80 to your computer and use it in GitHub Desktop.
Save ddimtirov/2c656155850d4c641201e0a905e25f80 to your computer and use it in GitHub Desktop.
JRE functional types

java.util.function types

Generic                    | Primitive specializations                    | Quick summary
---------------------------+----------------------------------------------+-----------------------------------------------------------------
Supplier       <A>         | (Int/Long/Double/Boolean)Supplier            | Returns a value 
                           |                                              |
Consumer       <A>         | (Int/Long/Double)Consumer                    | Processes a single argument
BiConsumer     <A1, A2>    | Obj(Int/Long/Double)Consumer<A1>             | Processes 2 arguments, the first one is always generic
                           |                                              |
Predicate      <A>         | (Int/Long/Double)Predicate                   | Takes an argument, returns a boolean
BiPredicate    <A1, A2>    |                                              | Takes 2 arguments, no primitives, returns a boolean
                           |                                              |
Function       <A, R>      | (Int/Long/Double)Function<R>                 | Takes an argument, returns a value.
                           | (Int/Long/Double)To(Int/Long/Double)Function | Provides implementations for all combinations of 
                           | To(Int/Long/Double)Function<A>               | generic, int, long, double for both arguments and retval
                           |                                              |
BiFunction     <A1, A2, R> | To(Int/Long/Double)BiFunction<A1, A2>        | Takes 2 generic arguments and returns a value
                           |                                              |
UnaryOperator  <T>         | (Int/Long/Double)UnaryOperator               | Takes an argument and returns a value of the same type
BinaryOperator <T>         | (Int/Long/Double)BinaryOperator              | Takes 2 arguments and returns a value of the same type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment