Default methods for SAM types

Brian Goetz brian.goetz at oracle.com
Sun Apr 14 15:48:11 PDT 2013


Here's a list of the default *instance* methods we've currently got (or 
should have, for consistency) for SAM types in java.util.function. 
Static methods will follow in a separate message.

Predicate<T>:

   Predicate<T> and(Predicate<? super T>)
   Predicate<T> or(Predicate<? super T>)
   Predicate<T> xor(Predicate<? super T>)
   Predicate<T> negate()

(same for {Int,Long,Double}Predicate, BiPredicate.)

Function<T,U>:

     <V> Function<V, R> compose(Function<? super V, ? extends T> before)
     <V> Function<T, V> andThen(Function<? super R, ? extends V> after)

BiFunction:

     <V> BiFunction<T, U, V> andThen(Function<? super R, ? extends V> after)

Consumer<T>:

     Consumer<T> chain(Consumer<? super T> other)

(Same for {Int,Long,Double}Consumer, BiConsumer.)

This seems a reasonable minimal set; not even clear whether 
BiFunction.andThen carries its weight.  Is there anything that's 
obviously missing?  Are there any of these that don't carry their weight?



More information about the lambda-libs-spec-observers mailing list