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 TypeMethodDescriptionConvertsfrom
to 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:ValueConverter
Convertsfrom
to an instance ofT
.- Specified by:
convert
in interfaceValueConverter<F,
T> - Parameters:
from
- the value from which to convert. May benull
- Returns:
- the
T
representation 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:ValueConverter
The 'converting from' type.- Specified by:
getFromType
in interfaceValueConverter<F,
T> - Returns:
- the type represented by
F
-
getToType
Description copied from interface:ValueConverter
The 'converting to' type.- Specified by:
getToType
in interfaceValueConverter<F,
T> - Returns:
- the type represented by
T
-
toString
-