Class ConvertUtils

java.lang.Object
org.hibernate.search.engine.cfg.spi.ConvertUtils

public final class ConvertUtils extends Object
  • Method Details

    • convert

      public 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.
      Type Parameters:
      T - The type of the returned value.
      Parameters:
      expectedType - the expected type
      parser - a parser from String to the expected type
      value - the value to convert (a String)
      Returns:
      the converted value
      Throws:
      SearchException - for invalid values.
    • convertBoolean

      public static Boolean convertBoolean(Object value)
      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

      public static Integer convertInteger(Object value)
      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

      public static Long convertLong(Object value)
      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

      public static Byte convertByte(Object value)
      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

      public static Short convertShort(Object value)
      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

      public static Float convertFloat(Object value)
      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

      public static Double convertDouble(Object value)
      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

      public static BigDecimal convertBigDecimal(Object value)
      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

      public static BigInteger convertBigInteger(Object value)
      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

      public static <T> List<T> convertMultiValue(Pattern separatorPattern, Function<Object,T> elementConverter, Object value)
    • trimIfString

      public static Object trimIfString(Object value)