Class ColumnMapping.Builder
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.db.ColumnMapping.Builder
-
- All Implemented Interfaces:
Builder<ColumnMapping>
- Enclosing class:
- ColumnMapping
public static class ColumnMapping.Builder extends java.lang.Object implements Builder<ColumnMapping>
Builder forColumnMapping.
-
-
Field Summary
Fields Modifier and Type Field Description private Configurationconfigurationprivate StringLayoutlayoutprivate java.lang.Stringliteralprivate java.lang.Stringnameprivate java.lang.Stringparameterprivate java.lang.Stringpatternprivate java.lang.Stringsourceprivate java.lang.Class<?>type
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColumnMappingbuild()Builds the object after all configuration has been set.ColumnMapping.BuildersetConfiguration(Configuration configuration)ColumnMapping.BuildersetLayout(StringLayout layout)Layout of value to write to database (before type conversion).ColumnMapping.BuildersetLiteral(java.lang.String literal)Literal value to use for populating a column.ColumnMapping.BuildersetName(java.lang.String name)Column name.ColumnMapping.BuildersetParameter(java.lang.String parameter)Parameter value to use for populating a column, MUST contain a single parameter marker '?'.ColumnMapping.BuildersetPattern(java.lang.String pattern)Pattern to use as aPatternLayout.ColumnMapping.BuildersetSource(java.lang.String source)Source name.ColumnMapping.BuildersetType(java.lang.Class<?> type)Class to convert value to before storing in database.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.core.util.Builder
getErrorPrefix, isValid
-
-
-
-
Field Detail
-
configuration
@PluginConfiguration private Configuration configuration
-
layout
@PluginElement("Layout") private StringLayout layout
-
literal
@PluginBuilderAttribute private java.lang.String literal
-
name
@PluginBuilderAttribute @Required(message="No column name provided") private java.lang.String name
-
parameter
@PluginBuilderAttribute private java.lang.String parameter
-
pattern
@PluginBuilderAttribute private java.lang.String pattern
-
source
@PluginBuilderAttribute private java.lang.String source
-
type
@PluginBuilderAttribute @Required(message="No conversion type provided") private java.lang.Class<?> type
-
-
Method Detail
-
build
public ColumnMapping build()
Description copied from interface:BuilderBuilds the object after all configuration has been set. This will use default values for any unspecified attributes for the object.- Specified by:
buildin interfaceBuilder<ColumnMapping>- Returns:
- the configured instance.
-
setConfiguration
public ColumnMapping.Builder setConfiguration(Configuration configuration)
-
setLayout
public ColumnMapping.Builder setLayout(StringLayout layout)
Layout of value to write to database (before type conversion). Not applicable ifsetType(Class)is aReadOnlyStringMap,ThreadContextMap, orThreadContextStack.- Returns:
- this.
-
setLiteral
public ColumnMapping.Builder setLiteral(java.lang.String literal)
Literal value to use for populating a column. This is generally useful for functions, stored procedures, etc. No escaping will be done on this value.- Returns:
- this.
-
setName
public ColumnMapping.Builder setName(java.lang.String name)
Column name.- Returns:
- this.
-
setParameter
public ColumnMapping.Builder setParameter(java.lang.String parameter)
Parameter value to use for populating a column, MUST contain a single parameter marker '?'. This is generally useful for functions, stored procedures, etc. No escaping will be done on this value.- Returns:
- this.
-
setPattern
public ColumnMapping.Builder setPattern(java.lang.String pattern)
Pattern to use as aPatternLayout. Convenient shorthand forsetLayout(StringLayout)with a PatternLayout.- Returns:
- this.
-
setSource
public ColumnMapping.Builder setSource(java.lang.String source)
Source name. Useful when combined with aMapMessagedepending on the appender.- Returns:
- this.
-
setType
public ColumnMapping.Builder setType(java.lang.Class<?> type)
Class to convert value to before storing in database. If the type is compatible withThreadContextMaporReadOnlyStringMap, then the MDC will be used. If the type is compatible withThreadContextStack, then the NDC will be used. If the type is compatible withDate, then the event timestamp will be used.- Returns:
- this.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-