eu.esdihumboldt.hale.common.convert
Class ConversionUtil
java.lang.Object
eu.esdihumboldt.hale.common.convert.ConversionUtil
public abstract class ConversionUtil
- extends Object
Conversion utilities.
- Author:
- Simon Templer
Method Summary |
static
|
getAs(Object value,
Class<T> targetType)
Convert a given value to the given target type. |
static
|
getAsList(Object value,
Class<T> targetType,
boolean flatten)
Convert a given value to a collection of target type values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConversionUtil
public ConversionUtil()
getAs
public static <T> T getAs(Object value,
Class<T> targetType)
throws org.springframework.core.convert.ConversionException
- Convert a given value to the given target type.
- Parameters:
value
- the value to converttargetType
- the target type
- Returns:
- the converted value
- Throws:
org.springframework.core.convert.ConversionException
- if the conversion failed
getAsList
public static <T> List<T> getAsList(Object value,
Class<T> targetType,
boolean flatten)
throws org.springframework.core.convert.ConversionException
- Convert a given value to a collection of target type values.
- Parameters:
value
- the value to converttargetType
- the target element typeflatten
- if the collection shall be flattened, i.e. if it in turn
contains a collection instead the converted values are added
- Returns:
- the collection of converted values, an empty list if the value
was
null
or an empty collection
- Throws:
org.springframework.core.convert.ConversionException
- if the conversion fails
Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d