TYPE
- Property value typeMODEL
- Model data typepublic interface PropertyValueConverter<TYPE,MODEL> extends Serializable
Property
type and a data model type, in both directions.
The fromModel(Object, Property)
and toModel(Object, Property)
methods should be symmetric, so that
chaining these together returns the original result for all inputs.
Property
Modifier and Type | Interface and Description |
---|---|
static class |
PropertyValueConverter.PropertyConversionException
Exception thrown when a property value conversion fails.
|
Modifier and Type | Method and Description |
---|---|
static <E extends Enum<E>> |
enumByName()
Create a
PropertyValueConverter which converts property values of given enum type into their
corresponding name String value and vice-versa. |
static <E extends Enum<E>> |
enumByOrdinal()
Create a
PropertyValueConverter which converts property values of given enum type into their
corresponding ordinal Integer value and vice-versa. |
TYPE |
fromModel(MODEL value,
Property<TYPE> property)
Convert given value from model data type to property value type
|
Class<MODEL> |
getModelType()
Get the model data type
|
Class<TYPE> |
getPropertyType()
Get the property type
|
static PropertyValueConverter<LocalDate,Date> |
localDate()
|
static PropertyValueConverter<LocalDateTime,Date> |
localDateTime()
|
static <N extends Number> |
numericBoolean(Class<N> modelType)
Create a numeric boolean
PropertyValueConverter which converts property values of numeric type
into boolean values using the following convention: null or 0 numeric values will be
converted as false boolean values, any other value will be converted as boolean true
value. |
MODEL |
toModel(TYPE value,
Property<TYPE> property)
Convert given value from property value type to model data type
|
TYPE fromModel(MODEL value, Property<TYPE> property) throws PropertyValueConverter.PropertyConversionException
value
- Value to convertproperty
- Target propertyPropertyValueConverter.PropertyConversionException
- Error converting valueMODEL toModel(TYPE value, Property<TYPE> property) throws PropertyValueConverter.PropertyConversionException
value
- Value to convertproperty
- Target propertyPropertyValueConverter.PropertyConversionException
- Error converting valuestatic <N extends Number> PropertyValueConverter<Boolean,N> numericBoolean(Class<N> modelType)
PropertyValueConverter
which converts property values of numeric type
into boolean values using the following convention: null
or 0
numeric values will be
converted as false
boolean values, any other value will be converted as boolean true
value.N
- Concrete Number model typemodelType
- Property value type (numeric)static <E extends Enum<E>> PropertyValueConverter<E,Integer> enumByOrdinal()
PropertyValueConverter
which converts property values of given enum
type into their
corresponding ordinal Integer
value and vice-versa.E
- Enum typestatic <E extends Enum<E>> PropertyValueConverter<E,String> enumByName()
PropertyValueConverter
which converts property values of given enum
type into their
corresponding name String
value and vice-versa.E
- Enum typestatic PropertyValueConverter<LocalDate,Date> localDate()
static PropertyValueConverter<LocalDateTime,Date> localDateTime()
Copyright © 2018 The Holon Platform. All rights reserved.