Class AbstractValueConverter<F,T>
java.lang.Object
com.soklet.converter.AbstractValueConverter<F,T>
- All Implemented Interfaces:
ValueConverter<F,T>
- Direct Known Subclasses:
FromStringValueConverter
@ThreadSafe
public abstract class AbstractValueConverter<F,T>
extends Object
implements ValueConverter<F,T>
Convenience superclass which provides default implementations of
ValueConverter methods.- Author:
- Mark Allen
-
Constructor Summary
ConstructorsConstructorDescriptionSupports subclasses that have both 'from' and 'to' generic types.AbstractValueConverter(Type fromType) Supports subclasses that have only a 'to' generic type, likeFromStringValueConverter. -
Method Summary
Modifier and TypeMethodDescriptionConvertsfromto an instance ofT.The 'converting from' type.The 'converting to' type.performConversion(F from) Subclasses must implement this method to convert a 'from' instance to a 'to' instance.toString()
-
Constructor Details
-
AbstractValueConverter
public AbstractValueConverter()Supports subclasses that have both 'from' and 'to' generic types. -
AbstractValueConverter
Supports subclasses that have only a 'to' generic type, likeFromStringValueConverter.- Parameters:
fromType- an explicitly-provided 'from' type
-
-
Method Details
-
convert
Description copied from interface:ValueConverterConvertsfromto an instance ofT.- Specified by:
convertin interfaceValueConverter<F,T> - Parameters:
from- the value from which to convert. May benull- Returns:
- the
Trepresentation offrom - Throws:
ValueConversionException- if an error occurs during conversion
-
performConversion
Subclasses must implement this method to convert a 'from' instance to a 'to' instance.- Parameters:
from- the instance we are converting from- Returns:
- an instance that was converted to
- Throws:
Exception- if an error occured during conversion
-
getFromType
Description copied from interface:ValueConverterThe 'converting from' type.- Specified by:
getFromTypein interfaceValueConverter<F,T> - Returns:
- the type represented by
F
-
getToType
Description copied from interface:ValueConverterThe 'converting to' type.- Specified by:
getToTypein interfaceValueConverter<F,T> - Returns:
- the type represented by
T
-
toString
-