net.sf.staccatocommons.defs
Interface ProtoMonad<Type,RawType,A>

Type Parameters:
RawType -
A -

public interface ProtoMonad<Type,RawType,A>

Very basic definition of a type that can act as a container or computation of other objects, with mapping, filtering and potentially asynchronous iteration capabilities

Since:
1.2
Author:
flbulgarelli

Method Summary
 Type each(Executable<? super A> block)
          Answers a ProtoMonad that executes the given block for each of its elements.
 Type filter(Evaluable<? super A> predicate)
          Preserves elements that satisfy the given predicate
 void forEach(Executable<? super A> block)
          Executes the given Executable for each element in this ProtoMonad.
<B> RawType
map(Applicable<? super A,? extends B> function)
          Transforms each element using the given function
 Type replace(A element, A replacement)
          Replaces all elements equal to the give one with the given replacement
 Type replaceNull(A replacement)
          Replaces all null elements with the given replacement
 Type skip(A element)
          Preserves all elements except those that are equal to the given one.
 Type skipNull()
          Preserves all elements except nulls Equivalent to filter(Predicates.notNull())
 

Method Detail

map

<B> RawType map(Applicable<? super A,? extends B> function)
Transforms each element using the given function

Type Parameters:
B -
Parameters:
function - the mapper used to transform each element, applying it
Returns:
a ProtoMonad that contains or computes the result of applying the given function to each element

filter

Type filter(Evaluable<? super A> predicate)
Preserves elements that satisfy the given predicate

Parameters:
predicate -
Returns:
a new ProtoMonad that will contain or compute only elements that evaluate to true

forEach

void forEach(@NonNull
             Executable<? super A> block)
Executes the given Executable for each element in this ProtoMonad. ProtoMonad does not guarantee that this message is evaluated synchronously or that elements are visited in any particular order

Parameters:
block -

skip

Type skip(@NonNull
          A element)
Preserves all elements except those that are equal to the given one. Equivalent to filter(Predicates.equal(element).not())

Parameters:
element -
Returns:
a ProtoMonad that contains or computes elements that are not equal to the given one

skipNull

Type skipNull()
Preserves all elements except nulls Equivalent to filter(Predicates.notNull())

Returns:
a ProtoMonad that contains or computes elements that are not null
Since:
2.1

replace

Type replace(@NonNull
             A element,
             A replacement)
Replaces all elements equal to the give one with the given replacement

Parameters:
element - the non null element to be replaced
replacement -
Returns:
a ProtoMonad that computes or contains the same elements that this, except of those equal to the given element, that are replaced by the given replacement
Since:
2.1

replaceNull

Type replaceNull(A replacement)
Replaces all null elements with the given replacement

Parameters:
replacement -
Returns:
a ProtoMonad that computes or contains the same elements that this, except of those null, which are replaced by the given replacement
Since:
2.1

each

Type each(@NonNull
          Executable<? super A> block)
Answers a ProtoMonad that executes the given block for each of its elements. This is equivalent to map(Functions.impure(block)

Parameters:
block -
Returns:
a ProtoMonad that computes or contains the same elements of this ProtoMonad, but adding to them and the environment the effects produced by the given block


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