org.javalite.activejdbc.conversion
Class ConverterAdapter<S,T>

java.lang.Object
  extended by org.javalite.activejdbc.conversion.ConverterAdapter<S,T>
Type Parameters:
S - Source type
T - Destination type
All Implemented Interfaces:
Converter<S,T>
Direct Known Subclasses:
StringToSqlDateConverter, StringToTimestampConverter

public abstract class ConverterAdapter<S,T>
extends Object
implements Converter<S,T>

Converts instances of S to T.

Author:
Eric Nielsen

Constructor Summary
ConverterAdapter()
           
 
Method Summary
 boolean canConvert(Class aSourceClass, Class aDestinationClass)
          Returns true if this converter can convert instances of sourceClass to destinationClass.
 T convert(S source)
          Converts instance of S to T.
protected abstract  Class<T> destinationClass()
           
protected abstract  T doConvert(S source)
          Converts instance of S to T.
protected abstract  Class<S> sourceClass()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConverterAdapter

public ConverterAdapter()
Method Detail

canConvert

public boolean canConvert(Class aSourceClass,
                          Class aDestinationClass)
Description copied from interface: Converter
Returns true if this converter can convert instances of sourceClass to destinationClass.

Specified by:
canConvert in interface Converter<S,T>
Parameters:
aSourceClass - source Class
aDestinationClass - destination Class
Returns:
true if this converter can convert instances of sourceClass to destinationClass, false otherwise

sourceClass

protected abstract Class<S> sourceClass()

destinationClass

protected abstract Class<T> destinationClass()

convert

public T convert(S source)
Description copied from interface: Converter
Converts instance of S to T.

Specified by:
convert in interface Converter<S,T>
Parameters:
source - instance of S
Returns:
instance of S converted to type T

doConvert

protected abstract T doConvert(S source)
                        throws Exception
Converts instance of S to T.

Parameters:
source - instance of S, can be null
Returns:
instance of S converted to type T
Throws:
Exception


Copyright © 2015 JavaLite. All rights reserved.