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 Configuration
configuration
private StringLayout
layout
private java.lang.String
literal
private java.lang.String
name
private java.lang.String
parameter
private java.lang.String
pattern
private java.lang.String
source
private java.lang.Class<?>
type
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColumnMapping
build()
Builds the object after all configuration has been set.ColumnMapping.Builder
setConfiguration(Configuration configuration)
ColumnMapping.Builder
setLayout(StringLayout layout)
Layout of value to write to database (before type conversion).ColumnMapping.Builder
setLiteral(java.lang.String literal)
Literal value to use for populating a column.ColumnMapping.Builder
setName(java.lang.String name)
Column name.ColumnMapping.Builder
setParameter(java.lang.String parameter)
Parameter value to use for populating a column, MUST contain a single parameter marker '?'.ColumnMapping.Builder
setPattern(java.lang.String pattern)
Pattern to use as aPatternLayout
.ColumnMapping.Builder
setSource(java.lang.String source)
Source name.ColumnMapping.Builder
setType(java.lang.Class<?> type)
Class to convert value to before storing in database.java.lang.String
toString()
-
-
-
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:Builder
Builds the object after all configuration has been set. This will use default values for any unspecified attributes for the object.- Specified by:
build
in 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 aMapMessage
depending 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 withThreadContextMap
orReadOnlyStringMap
, 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:
toString
in classjava.lang.Object
-
-