net.sf.mmm.util.value.impl
Class ValueConverterToCollection
java.lang.Object
net.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.value.base.AbstractValueConverter<SOURCE,TARGET>
net.sf.mmm.util.value.base.AbstractRecursiveValueConverter<Object,CONTAINER>
net.sf.mmm.util.value.impl.AbstractValueConverterToContainer<Collection>
net.sf.mmm.util.value.impl.ValueConverterToCollection
- All Implemented Interfaces:
- SimpleValueConverter<Object,Collection>, ValueConverter<Object,Collection>
@Singleton
@Named
public class ValueConverterToCollection
- extends AbstractValueConverterToContainer<Collection>
This is an implementation of the
ValueConverter
interface that converts an
Object
to a Collection
.
- Since:
- 1.0.1
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ValueConverterToCollection
public ValueConverterToCollection()
- The constructor.
getTargetType
public Class<Collection> getTargetType()
- Is the guaranteed return-type of the
conversion
. This information
is used externally to choose the most specific ValueConverter
that
is appropriate
for the conversion.
E.g. a generic converter can have 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.
Please note that the 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
.
- Returns:
- the target-type.
convertContainerEntry
protected void convertContainerEntry(Object element,
int index,
Collection container,
Object valueSource,
GenericType<? extends Collection> targetType,
Object value)
- This method converts a single entry of a container.
- Specified by:
convertContainerEntry
in class AbstractValueConverterToContainer<Collection>
- Parameters:
element
- is the single entry (element) of the container to convert.index
- is the index of the given element
in the order of
occurrence.container
- is the current container where to add the given
element
as entry.valueSource
- describes the source of the value or null
if NOT available.targetType
- is the target-type
to convert
to.value
- is the original value to convert.
createContainer
protected Collection createContainer(GenericType<? extends Collection> targetType,
int length)
- This method creates the according container for the given
containerType
.
- Specified by:
createContainer
in class AbstractValueConverterToContainer<Collection>
- Parameters:
targetType
- is the GenericType
of the container.length
- is the length (or capacity) of the container to create.
- Returns:
- the container instance.
Copyright © 2001-2010 mmm-Team. All Rights Reserved.