|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.beans.adapter.PropertynameMapToTypeAdapter<T>
T - public class PropertynameMapToTypeAdapter<T>
This class creates a proxy implementation for a given Class or interface type which is used as a facade to an
underlying Map<String,?>.
It supports the Converter annotation which allows to annotate getter and setter methods with ElementConverter
classes which are used to convert return values or the first available parameter if present. Be aware that if there are getter
and setter methods for the same property normally two different Converter annotations have to be set two support
conversion in two directions.
Also the PropertyNameTemplate Annotation is supported. This allows to specify alternative property names,
including dynamic names which are based on additional parameters of the method itself.
Further the DefaultValue and DefaultValues Annotation can be used to specify default values which are
used instead of the return value or parameter values in the case the return value or parameter value would be null.
Example:
{
Map<String, Object> map = new HashMap<String, Object>();
ExampleType exampleType = PropertynameMapToTypeAdapter.newInstance( map, ExampleType.class );
}
protected static interface ExampleType
{
@PropertyNameTemplate("fieldDoubleRenamed")
public Double getFieldDouble();
public void setFieldDouble( Double fieldDouble );
@Converter(type = ElementConverterIntegerToString.class)
public String getFieldString();
@Converter(type = ElementConverterStringToInteger.class)
public void setFieldString( String fieldString );
}
PropertynameMapToTypeAdapter.Configuration,
newInstance(Map, Class),
TypeToPropertynameMapAdapter,
SourcePropertyAccessorToTypeAdapter,
Converter,
PropertyNameTemplate,
PropertyAccessOption,
DefaultValue,
DefaultValues,
Serialized Form| Nested Class Summary | |
|---|---|
static interface |
PropertynameMapToTypeAdapter.Builder<T>
PropertynameMapToTypeAdapter.Builder which allows to create multiple instances based on the same Class type and PropertynameMapToTypeAdapter.Configuration. |
static class |
PropertynameMapToTypeAdapter.Configuration
The PropertynameMapToTypeAdapter.Configuration of a PropertynameMapToTypeAdapter includes following settings:PropertynameMapToTypeAdapter.Configuration.setSimulatingToString(boolean)
PropertynameMapToTypeAdapter.Configuration.setUnderlyingMapAware(boolean)
From the SourcePropertyAccessorToTypeAdapter.Configuration there are several more
settings available, too. |
protected static class |
PropertynameMapToTypeAdapter.SourePropertyAccessorForMap
|
| Method Summary | ||
|---|---|---|
static
|
builder(Class<? extends T> type,
PropertynameMapToTypeAdapter.Configuration configuration)
Returns a PropertynameMapToTypeAdapter.Builder for the given Class type and PropertynameMapToTypeAdapter.Configuration. |
|
static
|
newInstance(Map<String,Object> map,
Class<? extends T> type)
Factory methods to create a new PropertynameMapToTypeAdapter for a given Map with the given Class as
facade. |
|
static
|
newInstance(Map<String,Object> map,
Class<? extends T> type,
PropertynameMapToTypeAdapter.Configuration configuration)
Factory methods to create a new PropertynameMapToTypeAdapter for a given Map with the given Class as
facade. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> T newInstance(Map<String,Object> map,
Class<? extends T> type)
PropertynameMapToTypeAdapter for a given Map with the given Class as
facade.
map - type -
newInstance(Map, Class)
public static <T> T newInstance(Map<String,Object> map,
Class<? extends T> type,
PropertynameMapToTypeAdapter.Configuration configuration)
PropertynameMapToTypeAdapter for a given Map with the given Class as
facade.
map - type - configuration - PropertynameMapToTypeAdapter.Configuration
newInstance(Map, Class)
public static <T> PropertynameMapToTypeAdapter.Builder<T> builder(Class<? extends T> type,
PropertynameMapToTypeAdapter.Configuration configuration)
PropertynameMapToTypeAdapter.Builder for the given Class type and PropertynameMapToTypeAdapter.Configuration. A PropertynameMapToTypeAdapter.Builder is much faster in
creating many instances than the newInstance(Map, Class, Configuration) method. PropertynameMapToTypeAdapter.Configuration have to be stateless since they will be used by all
created instances of this PropertynameMapToTypeAdapter.Builder.
type - Classconfiguration - PropertynameMapToTypeAdapter.Configuration
PropertynameMapToTypeAdapter.Builder instance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||