gov.sandia.cognition.data.convert
Class AbstractReverseCachedDataConverter<InputType,OutputType,ReverseConverterType extends DataConverter<? super OutputType,? extends InputType>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.data.convert.AbstractDataConverter<InputType,OutputType>
          extended by gov.sandia.cognition.data.convert.AbstractReversibleDataConverter<InputType,OutputType>
              extended by gov.sandia.cognition.data.convert.AbstractReverseCachedDataConverter<InputType,OutputType,ReverseConverterType>
Type Parameters:
InputType - The input type to convert from.
OutputType - The output type to convert to.
ReverseConverterType - The type of the reverse converter.
All Implemented Interfaces:
DataConverter<InputType,OutputType>, ReversibleDataConverter<InputType,OutputType>, Evaluator<InputType,OutputType>, ReversibleEvaluator<InputType,OutputType,DataConverter<? super OutputType,? extends InputType>>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
DefaultBooleanToNumberConverter, StringToDoubleConverter, StringToIntegerConverter

public abstract class AbstractReverseCachedDataConverter<InputType,OutputType,ReverseConverterType extends DataConverter<? super OutputType,? extends InputType>>
extends AbstractReversibleDataConverter<InputType,OutputType>

Abstract implementation of ReversibleDataConverter that caches the reverse converter.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  ReverseConverterType reverse
          A cached value of the reverse converter.
 
Constructor Summary
AbstractReverseCachedDataConverter()
          Creates a new AbstractReverseCachedDataConverter.
 
Method Summary
protected abstract  ReverseConverterType createReverse()
          Creates a new reverse converter.
 ReverseConverterType reverse()
          Gets the data converter that performs the reverse conversion.
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 

Field Detail

reverse

protected transient ReverseConverterType extends DataConverter<? super OutputType,? extends InputType> reverse
A cached value of the reverse converter.

Constructor Detail

AbstractReverseCachedDataConverter

public AbstractReverseCachedDataConverter()
Creates a new AbstractReverseCachedDataConverter.

Method Detail

reverse

public ReverseConverterType reverse()
Gets the data converter that performs the reverse conversion.

Returns:
The reverse converter.

createReverse

protected abstract ReverseConverterType createReverse()
Creates a new reverse converter. Should only be called when there is a cache miss for this converter.

Returns:
The reverse converter.