Class ConvertUtils
java.lang.Object
org.hibernate.search.engine.cfg.spi.ConvertUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
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)
-
Method Details
-
convert
Convert a property value to a given class, either by casting it if possible or by treating it as a string to be parsed.- Type Parameters:
T
- The type of the returned value.- Parameters:
expectedType
- the expected typeparser
- a parser from String to the expected typevalue
- the value to convert (a String)- Returns:
- the converted value
- Throws:
SearchException
- for invalid values.
-
convertBoolean
Convert a property value from String to boolean if necessary, allowing only either "true" or "false".- Parameters:
value
- the value to convert (a Boolean, or a String to be parsed)- Returns:
- true if value is "true", false if value is "false"
- Throws:
SearchException
- for invalid format or values.
-
convertInteger
Convert a property value from String to int if necessary.- Parameters:
value
- the value to convert (a Number, or a String to be parsed)- Returns:
- the converted integer
- Throws:
SearchException
- for invalid format or values.
-
convertLong
Convert a property value from String to long if necessary.- Parameters:
value
- the value to convert (a Number, or a String to be parsed)- Returns:
- the converted long
- Throws:
SearchException
- for invalid format or values.
-
convertByte
Convert a property value from String to byte if necessary.- Parameters:
value
- the value to convert (a Number, or a String to be parsed)- Returns:
- the converted byte
- Throws:
SearchException
- for invalid format or values.
-
convertShort
Convert a property value from String to short if necessary.- Parameters:
value
- the value to convert (a Number, or a String to be parsed)- Returns:
- the converted short
- Throws:
SearchException
- for invalid format or values.
-
convertFloat
Convert a property value from String to float if necessary.- Parameters:
value
- the value to convert (a Number, or a String to be parsed)- Returns:
- the converted float
- Throws:
SearchException
- for invalid format or values.
-
convertDouble
Convert a property value from String to double if necessary.- Parameters:
value
- the value to convert (a Number, or a String to be parsed)- Returns:
- the converted double
- Throws:
SearchException
- for invalid format or values.
-
convertBigDecimal
Convert a property value from String to BigDecimal if necessary.- Parameters:
value
- the value to convert (a BigDecimal, a Number, or a String to be parsed)- Returns:
- the converted BigDecimal
- Throws:
SearchException
- for invalid format or values.
-
convertBigInteger
Convert a property value from String to BigInteger if necessary.- Parameters:
value
- the value to convert (a BigInteger, a Number, or a String to be parsed)- Returns:
- the converted BigInteger
- Throws:
SearchException
- for invalid format or values.
-
convertBeanReference
public static <T> BeanReference<? extends T> convertBeanReference(Class<T> expectedType, Object value) -
convertMultiValue
-
trimIfString
-