V
- is the generic type of the value.public class ValueConverterIdentity<V> extends AbstractSimpleValueConverter<V,V>
ValueConverter
that returns the unmodified
value (identity conversion).Modifier and Type | Field and Description |
---|---|
private Class<V> |
valueClass |
Constructor and Description |
---|
ValueConverterIdentity(Class<V> valueClass)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
<T extends V> |
convert(V value,
Object valueSource,
Class<T> targetClass)
This method converts the given
pojo to the <TARGET>-type. |
Class<V> |
getSourceType()
This the type of the value accepted by this converter.
|
Class<V> |
getTargetType()
Is the guaranteed return-type of the
conversion . |
convert
createLogger, doInitialize, getLogger
doInitialized, getInitializationState, initialize
private final Class<V> valueClass
getSourceType()
public Class<V> getSourceType()
Object
if you want to accept any
value. A very common source-type
is String
.public Class<V> getTargetType()
conversion
. This
information is used externally to choose the most specific ValueConverter
that is
appropriate
for the conversion. Object
as target-type
while a specific
converter may have Collection
as target-type
. Now if an object
(compliant with the source-type
) needs to be converted to a
Collection
or List
, the specific converter is used while for other
objects the generic converter is chosen. target-type
is often more general than the actual
returned result
. So a ValueConverter
that converts
a comma-separated String
to an ArrayList
will typically declare
List
as target-type
.public <T extends V> T convert(V value, Object valueSource, Class<T> targetClass) throws ValueException
pojo
to the <TARGET>-type.T
- is the generic type of targetClass
.value
- is the value to convert.valueSource
- describes the source of the value. This may be the filename where the value was read
from, an XPath where the value was located in an XML document, etc. It is used in exceptions
thrown if something goes wrong. This will help to find the problem easier.targetClass
- is the type to convert the value
to.value
or null
if the conversion is NOT possible. The
returned value has to be an instance
of the given
targetType
.ValueException
- if the conversion failed (e.g. the given value
is illegal for the
given targetClass
).ValueConverter.convert(Object, Object, GenericType)
Copyright © 2001–2014 mmm-Team. All rights reserved.