public final class TypeConverters extends Object
Collection of basic TypeConverter implementations. May be used to register additional TypeConverters or find registered TypeConverters.
2.1 Moved to the convert package.
  • Field Details

  • Constructor Details

    • TypeConverters

      public TypeConverters()
  • Method Details

    • convert

      public static <T> T convert(String s, Class<? extends T> clazz, Object defaultValue)
      Converts a String to a given class if a TypeConverter is available for that class. Falls back to the provided default value if the conversion is unsuccessful. However, if the default value is also invalid, then null is returned (along with a nasty status log message).
      s - the string to convert
      clazz - the class to try to convert the string to
      defaultValue - the fallback object to use if the conversion is unsuccessful
      the converted object which may be null if the string is invalid for the given type
      NullPointerException - if clazz is null
      IllegalArgumentException - if no TypeConverter exists for the given class