net.sf.molae.pipe.trafo
Interface TwoWayTransformer<S,T>

All Known Implementing Classes:
AbstractTransformer, CachedTransformer, ConstantSecondFactorTransformer, Extendable.ExtendableTransformer, FormatTransformer, InverseTransformer, MapAsTransformer, ProjectionTransformer, TransformedTransformer

public interface TwoWayTransformer<S,T>

Specifies both the methods to transform and to retransform an object. The interface foresees no exceptions for the transformation although in many cases the transformation is reasonable only for certain types of objects. Classes that use transformers that throw exceptions during transformation are responsible for handling these exceptions properly.

See Also:
TransformedCollection

Method Summary
 boolean isRetrievable(T input)
          Indicates if the origin of the specified object can be calculated.
 S retransform(T input)
          Calculates the transformation origin of the specified object (optional operation).
 T transform(S input)
          Transforms the input object (leaving it unchanged) into some output object.
 

Method Detail

transform

T transform(S input)
Transforms the input object (leaving it unchanged) into some output object.

Parameters:
input - the object to be transformed, should be left unchanged
Returns:
a transformed object
Throws:
ClassCastException - (runtime) if the input is the wrong class
IllegalArgumentException - (runtime) if the input is invalid

retransform

S retransform(T input)
Calculates the transformation origin of the specified object (optional operation). This is the inverse mapping of transform. If implemented, it must at least be ensured that
 transform(retransform(input)).equals(input)
 
for all objects, for that the retransformation is defined (that is retransform(input) does not throw an exception).
This implies that the retransformation is defined on a subset of the image of the transformation.

Parameters:
input - the object for which the transformation origin is searched.
Returns:
the transformation origin of the specified object.
Throws:
IllegalArgumentException - if the retransformation for the input object is not defined
ClassCastException - if the retransformation is not defined for the class of the input element
UnsupportedOperationException - if not implemented.

isRetrievable

boolean isRetrievable(T input)
Indicates if the origin of the specified object can be calculated. This requires that:
  1. retransform is implemented for this object and does not throw an exception.
  2. The object x returned by retransform is unique, or more formally: transform(o1).equals(transform(o2)) &rArr o1.equals(o2)
This implies that
 retransform(transform(input)).equals(input)
 
for all objects where the retransformation is defined.

Parameters:
input - the object for which the transformation origin is searched.
Returns:
true if the origin of the specified object can be calculated.
Throws:
ClassCastException - if the input value can not be cast to T.