Package lumis.util.converter
Class ConvertUtil
- java.lang.Object
-
- lumis.util.converter.ConvertUtil
-
public class ConvertUtil extends java.lang.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 java.util.Collection<T>>
java.util.Collection<T>convert(java.lang.Class<T> valueType, java.lang.Iterable input, R output, java.util.Locale locale, java.lang.String pattern)
static <T> T
convert(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale, java.lang.String pattern)
static <T> java.util.List<T>
convertAsList(java.lang.Class<T> valueType, java.lang.Object value, java.util.Locale locale, java.lang.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(java.lang.Class type)
Create the appropriated converter for the given type.static void
deregister(java.lang.Class type)
static void
register(java.lang.Class type, java.lang.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(java.lang.Class type, java.lang.Class<? extends IConverter> converterClass)
-
deregister
public static void deregister(java.lang.Class type)
-
createConverter
public static IConverter createConverter(java.lang.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> T convert(java.lang.Class<T> type, java.lang.Object value, java.util.Locale locale, java.lang.String pattern)
-
convert
public static <T,R extends java.util.Collection<T>> java.util.Collection<T> convert(java.lang.Class<T> valueType, java.lang.Iterable input, R output, java.util.Locale locale, java.lang.String pattern)
-
convertAsList
public static <T> java.util.List<T> convertAsList(java.lang.Class<T> valueType, java.lang.Object value, java.util.Locale locale, java.lang.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
-
-