de.unkrig.commons.lang.protocol
Interface ProducerWhichThrows<T,EX extends java.lang.Throwable>

Type Parameters:
T - The type of the products
EX - The throwable type that produce() may throw
All Known Subinterfaces:
DocumentScanner<TT>, StringScanner<TT>
All Known Implementing Classes:
AbstractScanner, StatefulScanner, StatelessScanner

public interface ProducerWhichThrows<T,EX extends java.lang.Throwable>

Like Producer, but the produce() method is permitted to throw e given exception.

IMPORTANT NOTICE:

When using this type in a variable, parameter or field declaration, never write
ProducerWhichThrows<product-type, thrown-exception>
, but always
ProducerWhichThrows<? extends product-type, ? extends thrown-exception>
.


Method Summary
 T produce()
          Produces the next instance of type T, a so-called 'product'.
 java.lang.String toString()
          Returns a human-readable text which describes the origin of the previously produced element, e.g. file name, line number and column number
 

Method Detail

produce

@Nullable
T produce()
          throws EX extends java.lang.Throwable
Produces the next instance of type T, a so-called 'product'. A null return value typically, but not necessarily indicates 'end-of-input'.

Generally products should either be immutable, or the 'ownership' of the product should pass from the producer to the caller. Particularly, the producer should not return one (mutable) instance more than once.

Throws:
EX extends java.lang.Throwable

toString

@Nullable
java.lang.String toString()
Returns a human-readable text which describes the origin of the previously produced element, e.g. file name, line number and column number

Overrides:
toString in class java.lang.Object