pl.clareo.coroutines.user
Interface CoIterator<E,A>

Type Parameters:
E - type of elements returned by coroutine
A - type of elements sent to coroutine

public interface CoIterator<E,A>

Interface encapsulating coroutine execution

Author:
Marcin Rzeźnicki

Method Summary
 void callWithPattern(A... toSend)
          As withPattern(Object...) but handy if you do not expect results.
 void close()
          Informs coroutine that no more operations will be performed.
 java.lang.Iterable<E> each()
          results of coroutine as Iterable.
 E next()
          Obtains next result from coroutine
 E send(A a)
          Obtains next result from coroutine and sends a to coroutine (in corutine a will become current yield result)
 java.lang.Iterable<E> till(E e)
          results of coroutine as Iterable.
 java.lang.Iterable<E> till(ExitCondition<E> condition)
          results of coroutine as Iterable.
 java.lang.Iterable<E> till(int count)
          results of coroutine as Iterable.
 java.lang.Iterable<E> with(Controler<E,A> controler)
          results of coroutine as Iterable.
 java.lang.Iterable<E> withPattern(A... toSend)
          results of coroutine as Iterable.
 

Method Detail

callWithPattern

void callWithPattern(A... toSend)
As withPattern(Object...) but handy if you do not expect results. It calls resulting Iterable till exhaustion and returns

Parameters:
toSend - parameters sent to coroutine

close

void close()
Informs coroutine that no more operations will be performed. Coroutine receives CoroutineExitException. Further calls to coroutine result in CoroutineClosedException in caller. All calls to close after the first one make no effect


each

java.lang.Iterable<E> each()
results of coroutine as Iterable. Iterator of result Iterable will return false from its hasNext method after coroutine throws NoSuchElementException or after it has been closed

Returns:
results of coroutine as Iterable

next

E next()
Obtains next result from coroutine

Returns:
next result
Throws:
CoroutineClosedException - if coroutine has been closed

send

E send(A a)
Obtains next result from coroutine and sends a to coroutine (in corutine a will become current yield result)

Parameters:
a - result of yield in coroutine
Returns:
next result
Throws:
CoroutineClosedException - if coroutine has been closed

till

java.lang.Iterable<E> till(E e)
results of coroutine as Iterable. Iterator of result Iterable will return false from its hasNext method after coroutine throws NoSuchElementException, after it has been closed or after last returned element is equals to e (or null if e is null). Coroutine is closed when this Iterable ends

Parameters:
e - element marking end of iteration (may be null)
Returns:
results of coroutine as Iterable

till

java.lang.Iterable<E> till(ExitCondition<E> condition)
results of coroutine as Iterable. Iterator of result Iterable will return false from its hasNext method after coroutine throws NoSuchElementException, after it has been closed or after condition evaluates to true. Coroutine is closed when this Iterable ends

Parameters:
condition - condition evaluated whenever coroutine yields
Returns:
results of coroutine as Iterable

till

java.lang.Iterable<E> till(int count)
results of coroutine as Iterable. Iterator of result Iterable will return false from its hasNext method after coroutine throws NoSuchElementException, after it has been closed or after it has been called count times. Coroutine is closed when this Iterable ends

Parameters:
count - number of desired results from coroutine
Returns:
results of coroutine as Iterable

with

java.lang.Iterable<E> with(Controler<E,A> controler)
results of coroutine as Iterable. Coroutine is controled by Controler instance passed to this method. Coroutine is closed when this Iterable ends

Parameters:
controler - coroutine's controler
Returns:
results of coroutine as Iterable

withPattern

java.lang.Iterable<E> withPattern(A... toSend)
results of coroutine as Iterable. Each result is obtained by calling send method. Parameters passed to send method are taken from toSend array in sequence. Coroutine is closed when this Iterable ends

Parameters:
toSend - parameters sent to coroutine
Returns:
results of coroutine as Iterable


Copyright © 2010 CLAREO. All Rights Reserved.