Class TypeConverterRegistry
- java.lang.Object
-
- org.apache.logging.log4j.core.config.plugins.convert.TypeConverterRegistry
-
public class TypeConverterRegistry extends java.lang.ObjectRegistry forTypeConverterplugins.- Since:
- 2.1
-
-
Field Summary
Fields Modifier and Type Field Description private static TypeConverterRegistryINSTANCEprivate static java.lang.ObjectINSTANCE_LOCKprivate static LoggerLOGGERprivate java.util.concurrent.ConcurrentMap<java.lang.reflect.Type,TypeConverter<?>>registry
-
Constructor Summary
Constructors Modifier Constructor Description privateTypeConverterRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeConverter<?>findCompatibleConverter(java.lang.reflect.Type type)Finds aTypeConverterfor the givenType, falling back to an assignment-compatible TypeConverter if none exist for the given type.static TypeConverterRegistrygetInstance()Gets the singleton instance of the TypeConverterRegistry.private static java.lang.reflect.TypegetTypeConverterSupportedType(java.lang.Class<? extends TypeConverter> typeConverterClass)private voidloadKnownTypeConverters(java.util.Collection<PluginType<?>> knownTypes)private TypeConverter<?>registerConverter(java.lang.reflect.Type conversionType, TypeConverter<?> converter)Attempts to register the given converter and returns the effective converter associated with the given type.private voidregisterPrimitiveTypes()private voidregisterTypeAlias(java.lang.reflect.Type knownType, java.lang.reflect.Type aliasType)
-
-
-
Field Detail
-
LOGGER
private static final Logger LOGGER
-
INSTANCE
private static volatile TypeConverterRegistry INSTANCE
-
INSTANCE_LOCK
private static final java.lang.Object INSTANCE_LOCK
-
registry
private final java.util.concurrent.ConcurrentMap<java.lang.reflect.Type,TypeConverter<?>> registry
-
-
Method Detail
-
getInstance
public static TypeConverterRegistry getInstance()
Gets the singleton instance of the TypeConverterRegistry.- Returns:
- the singleton instance.
-
findCompatibleConverter
public TypeConverter<?> findCompatibleConverter(java.lang.reflect.Type type)
Finds aTypeConverterfor the givenType, falling back to an assignment-compatible TypeConverter if none exist for the given type. That is, if the given Type does not have a TypeConverter, but another Type which can be assigned to the given Type does have a TypeConverter, then that TypeConverter will be used and registered.- Parameters:
type- the Type to find a TypeConverter for (must not benull).- Returns:
- a TypeConverter for the given Type.
- Throws:
java.util.UnknownFormatConversionException- if no TypeConverter can be found for the given type.
-
loadKnownTypeConverters
private void loadKnownTypeConverters(java.util.Collection<PluginType<?>> knownTypes)
-
registerConverter
private TypeConverter<?> registerConverter(java.lang.reflect.Type conversionType, TypeConverter<?> converter)
Attempts to register the given converter and returns the effective converter associated with the given type.Registration will fail if there already exists a converter for the given type and neither the existing, nor the provided converter extends from
Comparable.
-
getTypeConverterSupportedType
private static java.lang.reflect.Type getTypeConverterSupportedType(java.lang.Class<? extends TypeConverter> typeConverterClass)
-
registerPrimitiveTypes
private void registerPrimitiveTypes()
-
registerTypeAlias
private void registerTypeAlias(java.lang.reflect.Type knownType, java.lang.reflect.Type aliasType)
-
-