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

Type Parameters:
A - function argument type
B - function return type
All Superinterfaces:
Applicable<A,B>, Delayable<A,B>, NullSafeAware<Function<A,B>>

@Applicative
public interface Function<A,B>
extends Applicable<A,B>, NullSafeAware<Function<A,B>>, Delayable<A,B>

Functions are rich interfaced Applicables - one argument composable, Delayable and NullSafeAware tranformations.

Author:
flbulgarelli

Method Summary
 Predicate<A> equal(B object)
          Returns a predicate that answers if the result of applying this function is equals to the given object.
 boolean isIdentity()
          Answers if this function is the identity function, that is, the function that answers the argument it receives
 Predicate<A> notNull()
          Returns a predicate that answers if the result of applying this function is not null.
 Predicate<A> null_()
          Returns a predicate that answers if the result of applying this function is null.
 Function<A,B> nullSafe()
          Answers a new function that returns null if is argument is null, or the result of applying this function, otherwise.
<C> Function<C,B>
of(Applicable<? super C,? extends A> other)
          Composes this function with another Applicable, resulting in a new Function that when applied returns this.apply(other.apply(arg)
<Tp1,Tp2> Function2<Tp1,Tp2,B>
of(Applicable2<Tp1,Tp2,? extends A> other)
          Composes this function with another Applicable2, resulting in a new Function2 that when applied returns this.apply(other.apply(arg0, arg1)
<Tp1,Tp2,Tp3>
Function3<Tp1,Tp2,Tp3,B>
of(Applicable3<Tp1,Tp2,Tp3,? extends A> other)
          Composes this function with another Applicable3, resulting in a new Function3 that when applied returns this.apply(other.apply(arg0,arg1,arg2)
 Predicate<A> same(B object)
          Returns a predicate that answers if the result of applying this function is the same that the given object.
<C> Function<A,C>
then(Function<? super B,? extends C> other)
          Pipeline combination, equivalent to function composition, like but with receptor and argument interchanged.
<A2,B2,C> Function2<A,A2,C>
then(Function2<B,B2,C> binayFunction, Function<? super A2,? extends B2> other)
          Merge combination.
 Predicate<A> then(Predicate<? super B> other)
          Predicate composition, like Predicate.of(Applicable), but with receptor and argument interchanged.
 
Methods inherited from interface net.sf.staccatocommons.defs.Applicable
apply
 
Methods inherited from interface net.sf.staccatocommons.defs.Delayable
delayed, delayedValue
 

Method Detail

of

<C> Function<C,B> of(@NonNull
                     Applicable<? super C,? extends A> other)
Composes this function with another Applicable, resulting in a new Function that when applied returns this.apply(other.apply(arg)

Type Parameters:
C -
Parameters:
other -
Returns:
a new function, this composed with other

of

<Tp1,Tp2> Function2<Tp1,Tp2,B> of(@NonNull
                                  Applicable2<Tp1,Tp2,? extends A> other)
Composes this function with another Applicable2, resulting in a new Function2 that when applied returns this.apply(other.apply(arg0, arg1)

Type Parameters:
Tp1 -
Tp2 -
Parameters:
other - non null
Returns:
a new function, this composed with other. Non null.

of

<Tp1,Tp2,Tp3> Function3<Tp1,Tp2,Tp3,B> of(@NonNull
                                          Applicable3<Tp1,Tp2,Tp3,? extends A> other)
Composes this function with another Applicable3, resulting in a new Function3 that when applied returns this.apply(other.apply(arg0,arg1,arg2)

Type Parameters:
Tp1 -
Tp2 -
Tp3 -
Parameters:
other - non null
Returns:
a new function, this composed with other. Non null

then

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

Type Parameters:
C -
Parameters:
other -
Returns:
other.of(this)

then

<A2,B2,C> Function2<A,A2,C> then(Function2<B,B2,C> binayFunction,
                                 @NonNull
                                 Function<? super A2,? extends B2> other)
Merge combination. Answers a two 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 argument, the other function to the second 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 Function2 that merges this and other with binaryFunction
Since:
1.2

then

Predicate<A> then(@NonNull
                  Predicate<? super B> other)
Predicate composition, like Predicate.of(Applicable), but with receptor and argument interchanged. Equivalent to other.of(this)

Parameters:
other -
Returns:
a new Predicate

nullSafe

@NullSafe
Function<A,B> nullSafe()
Answers a new function that returns null if is argument is null, or the result of applying this function, otherwise.

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

equal

Predicate<A> equal(B object)
Returns a predicate that answers if the result of applying this function is equals to the given object. For example, the following snippet:
 NumberType<Integer> integerType = ...;
 integerType.add(10).equal(15).apply(5);
 
will be true, since 5 + 10 = 15

Parameters:
other -
Returns:
a new Predicate

same

Predicate<A> same(B object)
Returns a predicate that answers if the result of applying this function is the same that the given object.

Parameters:
other -
Returns:
a new Predicate

null_

Predicate<A> null_()
Returns a predicate that answers if the result of applying this function is null.

Parameters:
other -
Returns:
a new Predicate

notNull

Predicate<A> notNull()
Returns a predicate that answers if the result of applying this function is not null.

Parameters:
other -
Returns:
a new Predicate

isIdentity

boolean isIdentity()
Answers if this function is the identity function, that is, the function that answers the argument it receives

Returns:
if this function is the identity


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