public final class ConvertUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
convert(Class<T> expectedType,
Function<String,T> parser,
Object value)
Convert a property value to a given class, either by casting it if possible
or by treating it as a string to be parsed.
|
static <T> BeanReference<? extends T> |
convertBeanReference(Class<T> expectedType,
Object value) |
static BigDecimal |
convertBigDecimal(Object value)
Convert a property value from String to BigDecimal if necessary.
|
static BigInteger |
convertBigInteger(Object value)
Convert a property value from String to BigInteger if necessary.
|
static Boolean |
convertBoolean(Object value)
Convert a property value from String to boolean if necessary, allowing only either "true" or "false".
|
static Byte |
convertByte(Object value)
Convert a property value from String to byte if necessary.
|
static Double |
convertDouble(Object value)
Convert a property value from String to double if necessary.
|
static Float |
convertFloat(Object value)
Convert a property value from String to float if necessary.
|
static Integer |
convertInteger(Object value)
Convert a property value from String to int if necessary.
|
static Long |
convertLong(Object value)
Convert a property value from String to long if necessary.
|
static <T> List<T> |
convertMultiValue(Pattern separatorPattern,
Function<Object,T> elementConverter,
Object value) |
static Short |
convertShort(Object value)
Convert a property value from String to short if necessary.
|
static Object |
trimIfString(Object value) |
public static <T> T convert(Class<T> expectedType, Function<String,T> parser, Object value)
T - The type of the returned value.expectedType - the expected typeparser - a parser from String to the expected typevalue - the value to convert (a String)SearchException - for invalid values.public static Boolean convertBoolean(Object value)
value - the value to convert (a Boolean, or a String to be parsed)SearchException - for invalid format or values.public static Integer convertInteger(Object value)
value - the value to convert (a Number, or a String to be parsed)SearchException - for invalid format or values.public static Long convertLong(Object value)
value - the value to convert (a Number, or a String to be parsed)SearchException - for invalid format or values.public static Byte convertByte(Object value)
value - the value to convert (a Number, or a String to be parsed)SearchException - for invalid format or values.public static Short convertShort(Object value)
value - the value to convert (a Number, or a String to be parsed)SearchException - for invalid format or values.public static Float convertFloat(Object value)
value - the value to convert (a Number, or a String to be parsed)SearchException - for invalid format or values.public static Double convertDouble(Object value)
value - the value to convert (a Number, or a String to be parsed)SearchException - for invalid format or values.public static BigDecimal convertBigDecimal(Object value)
value - the value to convert (a BigDecimal, a Number, or a String to be parsed)SearchException - for invalid format or values.public static BigInteger convertBigInteger(Object value)
value - the value to convert (a BigInteger, a Number, or a String to be parsed)SearchException - for invalid format or values.public static <T> BeanReference<? extends T> convertBeanReference(Class<T> expectedType, Object value)
public static <T> List<T> convertMultiValue(Pattern separatorPattern, Function<Object,T> elementConverter, Object value)
Copyright © 2006-2020 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.