Package org.xwiki.properties.converter
Class AbstractConverter<T>
- java.lang.Object
-
- org.xwiki.properties.converter.AbstractConverter<T>
-
- Type Parameters:
T
- the type in which the provided value has to be converted
- All Implemented Interfaces:
Converter<T>
- Direct Known Subclasses:
AbstractCollectionConverter
public abstract class AbstractConverter<T> extends Object implements Converter<T>
Helper base class for aConverter
component.Commonly a new component is supposed to implements
convertToString(Object)
andconvertToType(Class, Object)
.- Since:
- 2.0M2
- Version:
- $Id: 1ab948f1f76935985bc9d433afff884dfda7650b $
-
-
Constructor Summary
Constructors Constructor Description AbstractConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <G> G
convert(Type targetType, Object sourceValue)
Convert the specified input object into an output object of the specified type.protected String
convertToString(T value)
Convert the input object into a String.protected <G extends T>
GconvertToType(Class<G> type, Object value)
Deprecated.since 3.0M1 overwriteconvertToType(Type, Object)
insteadprotected <G extends T>
GconvertToType(Type targetType, Object value)
Convert the input object into an output object of the specified type.
-
-
-
Method Detail
-
convert
public <G> G convert(Type targetType, Object sourceValue)
Description copied from interface:Converter
Convert the specified input object into an output object of the specified type.
-
convertToString
protected String convertToString(T value)
Convert the input object into a String.N.B.This implementation simply uses the value's
toString()
method and should be overridden if a more sophisticated mechanism for conversion to a String is required.- Parameters:
value
- The input value to be converted.- Returns:
- the converted String value.
-
convertToType
protected <G extends T> G convertToType(Type targetType, Object value)
Convert the input object into an output object of the specified type.Typical implementations will provide a minimum of
String --> type
conversion.- Type Parameters:
G
- the type in which the provided value has o be converted- Parameters:
targetType
- Data type to which this value should be converted.value
- The input value to be converted.- Returns:
- The converted value.
- Since:
- 3.0M1
-
convertToType
@Deprecated protected <G extends T> G convertToType(Class<G> type, Object value)
Deprecated.since 3.0M1 overwriteconvertToType(Type, Object)
insteadConvert the input object into an output object of the specified type.Typical implementations will provide a minimum of
String --> type
conversion.- Type Parameters:
G
- the type in which the provided value has o be converted- Parameters:
type
- Data type to which this value should be converted.value
- The input value to be converted.- Returns:
- The converted value.
-
-