Class AbstractPluginVisitor<A extends java.lang.annotation.Annotation>
- java.lang.Object
-
- org.apache.logging.log4j.core.config.plugins.visitors.AbstractPluginVisitor<A>
-
- Type Parameters:
A
- the Plugin annotation type.
- All Implemented Interfaces:
PluginVisitor<A>
- Direct Known Subclasses:
PluginAttributeVisitor
,PluginBuilderAttributeVisitor
,PluginConfigurationVisitor
,PluginElementVisitor
,PluginNodeVisitor
,PluginValueVisitor
public abstract class AbstractPluginVisitor<A extends java.lang.annotation.Annotation> extends java.lang.Object implements PluginVisitor<A>
Base class for PluginVisitor implementations. Provides convenience methods as well as all method implementations other than thevisit
method.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]
aliases
protected A
annotation
protected java.lang.Class<A>
clazz
protected java.lang.Class<?>
conversionType
protected static Logger
LOGGER
Status logger.protected java.lang.reflect.Member
member
protected StrSubstitutor
substitutor
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPluginVisitor(java.lang.Class<A> clazz)
This constructor must be overridden by implementation classes as a no-arg constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
convert(java.lang.String value, java.lang.Object defaultValue)
Converts the given value into the configured type falling back to the provided default value.protected static java.lang.String
removeAttributeValue(java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.String name, java.lang.String... aliases)
Removes an Entry from a given Map using a key name and aliases for that key.PluginVisitor<A>
setAliases(java.lang.String... someAliases)
Sets the list of aliases to use for this visit.PluginVisitor<A>
setAnnotation(java.lang.annotation.Annotation anAnnotation)
Sets the Annotation to be used for this.PluginVisitor<A>
setConversionType(java.lang.Class<?> aConversionType)
Sets the class to convert the plugin value to on this visit.PluginVisitor<A>
setMember(java.lang.reflect.Member aMember)
Sets the Member that this visitor is being used for injection upon.PluginVisitor<A>
setStrSubstitutor(StrSubstitutor aSubstitutor)
Sets the StrSubstitutor to use for converting raw strings before type conversion.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.core.config.plugins.visitors.PluginVisitor
visit
-
-
-
-
Field Detail
-
LOGGER
protected static final Logger LOGGER
Status logger.
-
clazz
protected final java.lang.Class<A extends java.lang.annotation.Annotation> clazz
-
annotation
protected A extends java.lang.annotation.Annotation annotation
-
aliases
protected java.lang.String[] aliases
-
conversionType
protected java.lang.Class<?> conversionType
-
substitutor
protected StrSubstitutor substitutor
-
member
protected java.lang.reflect.Member member
-
-
Constructor Detail
-
AbstractPluginVisitor
protected AbstractPluginVisitor(java.lang.Class<A> clazz)
This constructor must be overridden by implementation classes as a no-arg constructor.- Parameters:
clazz
- the annotation class this PluginVisitor is for.
-
-
Method Detail
-
setAnnotation
public PluginVisitor<A> setAnnotation(java.lang.annotation.Annotation anAnnotation)
Description copied from interface:PluginVisitor
Sets the Annotation to be used for this. If the given Annotation is not compatible with this class's type, then it is ignored.- Specified by:
setAnnotation
in interfacePluginVisitor<A extends java.lang.annotation.Annotation>
- Parameters:
anAnnotation
- the Annotation instance.- Returns:
this
.
-
setAliases
public PluginVisitor<A> setAliases(java.lang.String... someAliases)
Description copied from interface:PluginVisitor
Sets the list of aliases to use for this visit. No aliases are required, however.- Specified by:
setAliases
in interfacePluginVisitor<A extends java.lang.annotation.Annotation>
- Parameters:
someAliases
- the list of aliases to use.- Returns:
this
.
-
setConversionType
public PluginVisitor<A> setConversionType(java.lang.Class<?> aConversionType)
Description copied from interface:PluginVisitor
Sets the class to convert the plugin value to on this visit. This should correspond with a class obtained from a factory method or builder class field. Not all PluginVisitor implementations may need this value.- Specified by:
setConversionType
in interfacePluginVisitor<A extends java.lang.annotation.Annotation>
- Parameters:
aConversionType
- the type to convert the plugin string to (if applicable).- Returns:
this
.
-
setStrSubstitutor
public PluginVisitor<A> setStrSubstitutor(StrSubstitutor aSubstitutor)
Description copied from interface:PluginVisitor
Sets the StrSubstitutor to use for converting raw strings before type conversion. Generally obtained from aConfiguration
.- Specified by:
setStrSubstitutor
in interfacePluginVisitor<A extends java.lang.annotation.Annotation>
- Parameters:
aSubstitutor
- the StrSubstitutor to use on plugin values.- Returns:
this
.
-
setMember
public PluginVisitor<A> setMember(java.lang.reflect.Member aMember)
Description copied from interface:PluginVisitor
Sets the Member that this visitor is being used for injection upon. For instance, this could be the Field that is being used for injecting a value, or it could be the factory method being used to inject parameters into.- Specified by:
setMember
in interfacePluginVisitor<A extends java.lang.annotation.Annotation>
- Parameters:
aMember
- the member this visitor is parsing a value for.- Returns:
this
.
-
removeAttributeValue
protected static java.lang.String removeAttributeValue(java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.String name, java.lang.String... aliases)
Removes an Entry from a given Map using a key name and aliases for that key. Keys are case-insensitive.- Parameters:
attributes
- the Map to remove an Entry from.name
- the key name to look up.aliases
- optional aliases of the key name to look up.- Returns:
- the value corresponding to the given key or
null
if nonexistent.
-
convert
protected java.lang.Object convert(java.lang.String value, java.lang.Object defaultValue)
Converts the given value into the configured type falling back to the provided default value.- Parameters:
value
- the value to convert.defaultValue
- the fallback value to use in case of no value or an error.- Returns:
- the converted value whether that be based on the given value or the default value.
-
-