Package com.oorian.data.converter
Class ConverterRegistry
java.lang.Object
com.oorian.data.converter.ConverterRegistry
Registry for bidirectional type converters.
Provides automatic lookup of Converter instances by presentation and model
type pair. All built-in converters are pre-registered at class-load time.
Usage:
// Look up a built-in converter
Converter<String, Integer> converter = ConverterRegistry.find(String.class, Integer.class);
// Register a custom converter
ConverterRegistry.register(String.class, Money.class, new StringToMoneyConverter());
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <P,M> Converter <P, M> Finds a converter for the given presentation and model type pair.static <P,M> void Registers a converter for the given presentation and model type pair.static voidRemoves the converter registered for the given type pair.
-
Method Details
-
register
public static <P,M> void register(Class<P> presentationType, Class<M> modelType, Converter<P, M> converter) Registers a converter for the given presentation and model type pair.If a converter is already registered for the same type pair, it is replaced.
- Type Parameters:
P- the presentation typeM- the model type- Parameters:
presentationType- the presentation classmodelType- the model classconverter- the converter instance
-
find
Finds a converter for the given presentation and model type pair.- Type Parameters:
P- the presentation typeM- the model type- Parameters:
presentationType- the presentation classmodelType- the model class- Returns:
- the converter, or
nullif none is registered
-
remove
Removes the converter registered for the given type pair.- Parameters:
presentationType- the presentation classmodelType- the model class
-