java.lang.Object
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters

public final class TypeConverters extends Object
Collection of basic TypeConverter implementations. May be used to register additional TypeConverters or find registered TypeConverters.
Since:
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).
      Parameters:
      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
      Returns:
      the converted object which may be null if the string is invalid for the given type
      Throws:
      NullPointerException - if clazz is null
      IllegalArgumentException - if no TypeConverter exists for the given class