Class ConverterAdapter<S,​T>

java.lang.Object
org.javalite.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 Details

    • ConverterAdapter

      public ConverterAdapter()
  • Method Details

    • 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