net.sf.staccatocommons.defs.function
Interface Function2<A,B,C>

Type Parameters:
A - function first argument type
B - function second argument type
C - function return type
All Superinterfaces:
Applicable<A,Function<B,C>>, Applicable2<A,B,C>, Delayable2<A,B,C>, NullSafeAware<Function2<A,B,C>>

@Applicative
public interface Function2<A,B,C>
extends Applicable2<A,B,C>, Applicable<A,Function<B,C>>, Delayable2<A,B,C>, NullSafeAware<Function2<A,B,C>>

Function2s are rich interfaced Applicable2s - two arguments Delayable2 and NullSafeAware transformations. Function2 can also be partially applied, which means, applying it with less arguments than required, returning, instead of the result of the transformation, a new function that expects the rest of the arguments. Thus, Function2 do also implement Applicable

Author:
flbulgarelli

Method Summary
 Function<B,C> apply(A arg0)
          Partially applies the function passing just its first parameter
 C apply(A arg0, B arg1)
          Applies the function
 Function2<B,A,C> flip()
          Inverts function parameters order
 Function2<A,B,C> nullSafe()
          Answers a new function that returns null if any of its arguments is null, or the result of applying this function, otherwise.
<D> Function2<D,B,C>
of(Applicable<? super D,? extends A> function)
           
<D> Function2<A,B,D>
then(Function<? super C,? extends D> other)
          Function composition, like Function.of(Applicable2), but with receptor and argument interchanged.
<A2,B2,D> Function3<A,B,A2,D>
then(Function2<C,B2,D> binaryFunction, Function<? super A2,? extends B2> other)
          Answers a three arg function that combines this function with other function, using a binaryFunction to merge the results.
 Function<Tuple2<A,B>,C> uncurry()
          Uncurries this function, by returning a Function that takes a single pair, being its components each of the original function parameters
 
Methods inherited from interface net.sf.staccatocommons.defs.Delayable2
delayed, delayedValue
 

Method Detail

apply

Function<B,C> apply(A arg0)
Partially applies the function passing just its first parameter

Specified by:
apply in interface Applicable<A,Function<B,C>>
Parameters:
arg0 - the transformation
Returns:
the transformation result

apply

C apply(A arg0,
        B arg1)
Applies the function

Specified by:
apply in interface Applicable2<A,B,C>
Parameters:
arg0 - the first transformation argument
arg1 - the second transformation argument
Returns:
the transformation result

flip

Function2<B,A,C> flip()
Inverts function parameters order

Returns:
a new Function2 that produces the same result of this one when applied, but with arguments flipped

nullSafe

@NullSafe
Function2<A,B,C> nullSafe()
Answers a new function that returns null if any of its arguments is null, or the result of applying this function, otherwise.

Specified by:
nullSafe in interface NullSafeAware<Function2<A,B,C>>
Returns:
a new null-safe Function2

of

<D> Function2<D,B,C> of(Applicable<? super D,? extends A> function)
Type Parameters:
D -
Parameters:
function -
Returns:
Since:
1.2

then

<D> Function2<A,B,D> then(@NonNull
                          Function<? super C,? extends D> other)
Function composition, like Function.of(Applicable2), but with receptor and argument interchanged. Equivalent to other.of(this) Functions get combined in the following figure:
 >----+
      +--this---+---other---->
 >----+
 

Type Parameters:
C -
Parameters:
other -
Returns:
a new Function2
Since:
1.2

then

<A2,B2,D> Function3<A,B,A2,D> then(Function2<C,B2,D> binaryFunction,
                                   @NonNull
                                   Function<? super A2,? extends B2> other)
Answers a three arg function that combines this function with other function, using a binaryFunction to merge the results. The answered Function2 will apply this function to its first and second argument argument, other function to the third argument, and return the application of binaryFunction to both resulting values. Functions get combined in the following figure:
 >----+
      +--this-+
 >----+       +---binaryFunction---->
              |
 >--other-----+
 

Type Parameters:
A2 -
B2 -
C -
Parameters:
binayFunction -
other -
Returns:
a new Function3 the merges this and other using the binaryFunciton
Since:
1.2

uncurry

Function<Tuple2<A,B>,C> uncurry()
Uncurries this function, by returning a Function that takes a single pair, being its components each of the original function parameters

Returns:
a new Function


Get Staccatocommons at SourceForge.net. Fast, secure and Free Open Source software downloads