Package lumis.util.converter
Class ConvertUtil
- java.lang.Object
-
- lumis.util.converter.ConvertUtil
-
public class ConvertUtil extends Object
This class offers utility conversion methods.- Since:
- 4.0.4
- Version:
- $Revision: 24221 $ $Date: 2020-11-09 20:23:09 -0300 (Mon, 09 Nov 2020) $
-
-
Field Summary
Fields Modifier and Type Field Description static IConverter
DELEGATE_TO_REGISTERED_CONVERTER
A converter that delegates calls to it to a registered converter.
-
Constructor Summary
Constructors Constructor Description ConvertUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R extends Collection<T>>
Collection<T>convert(Class<T> valueType, Iterable input, R output, Locale locale, String pattern)
static <T> T
convert(Class<T> type, Object value, Locale locale, String pattern)
static <T> List<T>
convertAsList(Class<T> valueType, Object value, Locale locale, String pattern)
Converts the given value as a list.
If the given value isIterable
, then its inner elements will be converted to <T>, usingconvert(Class, Object, Locale, String)
, and then they will be added in a resultList
.
If the given value is notIterable
, then it will be converted and then it will be added to a resultList
.
The result list isSerializable
and modifiable.static IConverter
createConverter(Class type)
Create the appropriated converter for the given type.static void
deregister(Class type)
static void
register(Class type, Class<? extends IConverter> converterClass)
-
-
-
Field Detail
-
DELEGATE_TO_REGISTERED_CONVERTER
public static final IConverter DELEGATE_TO_REGISTERED_CONVERTER
A converter that delegates calls to it to a registered converter.- Since:
- 4.0.4
- See Also:
DelegateToRegisteredConverter
-
-
Method Detail
-
register
public static void register(Class type, Class<? extends IConverter> converterClass)
-
deregister
public static void deregister(Class type)
-
createConverter
public static IConverter createConverter(Class type) throws UnsupportedConversionTypeException
Create the appropriated converter for the given type.- Parameters:
type
- the type that needs to be converted.- Returns:
- an instance of the appropriated converter for the given type.
- Throws:
UnsupportedConversionTypeException
- if the conversion is not supported.- Since:
- 6.0.0
-
convert
public static <T,R extends Collection<T>> Collection<T> convert(Class<T> valueType, Iterable input, R output, Locale locale, String pattern)
-
convertAsList
public static <T> List<T> convertAsList(Class<T> valueType, Object value, Locale locale, String pattern)
Converts the given value as a list.
If the given value isIterable
, then its inner elements will be converted to <T>, usingconvert(Class, Object, Locale, String)
, and then they will be added in a resultList
.
If the given value is notIterable
, then it will be converted and then it will be added to a resultList
.
The result list isSerializable
and modifiable.- Parameters:
valueType
- the value type class.value
- the value itself, either a raw value or an iterable of raw values.locale
- the locale.pattern
- the pattern.- Returns:
- the result list.
- Since:
- 11.0.0
-
-