Class TypeConverterRegistry
java.lang.Object
org.apache.logging.log4j.core.config.plugins.convert.TypeConverterRegistry
Registry for
TypeConverter plugins.- Since:
- 2.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static TypeConverterRegistryprivate static final Objectprivate static final Loggerprivate final ConcurrentMap<Type, TypeConverter<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindCompatibleConverter(Type type) Finds aTypeConverterfor the givenType, falling back to an assignment-compatible TypeConverter if none exist for the given type.static TypeConverterRegistryGets the singleton instance of the TypeConverterRegistry.private static TypegetTypeConverterSupportedType(Class<? extends TypeConverter> typeConverterClass) private voidloadKnownTypeConverters(Collection<PluginType<?>> knownTypes) private TypeConverter<?> registerConverter(Type conversionType, TypeConverter<?> converter) Attempts to register the given converter and returns the effective converter associated with the given type.private voidprivate voidregisterTypeAlias(Type knownType, Type aliasType)
-
Field Details
-
LOGGER
-
INSTANCE
-
INSTANCE_LOCK
-
registry
-
-
Constructor Details
-
TypeConverterRegistry
private TypeConverterRegistry()
-
-
Method Details
-
getInstance
Gets the singleton instance of the TypeConverterRegistry.- Returns:
- the singleton instance.
-
findCompatibleConverter
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:
UnknownFormatConversionException- if no TypeConverter can be found for the given type.
-
loadKnownTypeConverters
-
registerConverter
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 Type getTypeConverterSupportedType(Class<? extends TypeConverter> typeConverterClass) -
registerPrimitiveTypes
private void registerPrimitiveTypes() -
registerTypeAlias
-