public class ConfigBuilder extends ContextBuilder
Configs
.
Config cf = Config.
Constructor and Description |
---|
ConfigBuilder()
Constructor, default settings.
|
ConfigBuilder(PropertyStore ps)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ConfigBuilder |
add(Map<String,Object> properties)
Adds multiple free-form configuration properties on this object without first clearing out any previous values.
|
ConfigBuilder |
addTo(String name,
Object value)
Adds a free-form value to a SET property.
|
ConfigBuilder |
appendTo(String name,
Object value)
Adds a free-form value to the end of a LIST property.
|
ConfigBuilder |
apply(PropertyStore copyFrom)
Copies the settings from the specified property store into this builder.
|
ConfigBuilder |
applyAnnotations(AnnotationList al,
VarResolverSession r)
Applies a set of annotations to this property store.
|
ConfigBuilder |
applyAnnotations(Class<?>... fromClasses)
Applies any of the various
|
ConfigBuilder |
applyAnnotations(Method... fromMethods)
Applies any of the various
|
ConfigBuilder |
binaryFormat(BinaryFormat value)
|
ConfigBuilder |
binaryLineLength(int value)
|
Config |
build()
Build the object.
|
ConfigBuilder |
debug()
|
ConfigBuilder |
encoder(Class<? extends ConfigEncoder> value)
|
ConfigBuilder |
encoder(ConfigEncoder value)
|
ConfigBuilder |
locale(Locale value)
|
ConfigBuilder |
mediaType(MediaType value)
|
ConfigBuilder |
memStore()
|
ConfigBuilder |
multiLineValuesOnSeparateLines()
|
ConfigBuilder |
name(String value)
|
ConfigBuilder |
parser(Class<? extends ReaderParser> value)
|
ConfigBuilder |
parser(ReaderParser value)
|
ConfigBuilder |
prependTo(String name,
Object value)
Adds a free-form value to the beginning of a LIST property.
|
ConfigBuilder |
putAllTo(String name,
Object value)
Adds or overwrites multiple free-form entries in a MAP property.
|
ConfigBuilder |
putTo(String name,
String key,
Object value)
Adds or overwrites a free-form entry in a MAP property.
|
ConfigBuilder |
readOnly()
|
ConfigBuilder |
removeFrom(String name,
Object value)
Removes a free-form value from a SET, LIST, or MAP property.
|
ConfigBuilder |
serializer(Class<? extends WriterSerializer> value)
|
ConfigBuilder |
serializer(WriterSerializer value)
|
ConfigBuilder |
set(Map<String,Object> properties)
Sets multiple free-form configuration properties on this object replacing all previous values.
|
ConfigBuilder |
set(String name,
Object value)
Sets a free-form configuration property on this object.
|
ConfigBuilder |
store(ConfigStore value)
|
ConfigBuilder |
timeZone(TimeZone value)
|
ConfigBuilder |
varResolver(Class<? extends VarResolver> value)
|
ConfigBuilder |
varResolver(VarResolver value)
|
build, getPropertyStore, getPropertyStoreBuilder, peek, peek
public ConfigBuilder()
public ConfigBuilder(PropertyStore ps)
ps
- The initial configuration settings for this builder.public Config build()
ContextBuilder
build
in class ContextBuilder
public ConfigBuilder name(String value)
Specifies the configuration name.
This is typically the configuration file name, although
the name can be anything identifiable by the ConfigStore
used for retrieving and storing the configuration.
value
- The new value for this property.
public ConfigBuilder store(ConfigStore value)
The configuration store used for retrieving and storing configurations.
value
- The new value for this property.
ConfigFileStore.DEFAULT
.public ConfigBuilder memStore()
Convenience method for calling store(ConfigMemoryStore.
.
public ConfigBuilder serializer(WriterSerializer value)
The serializer to use for serializing POJO values.
value
- The new value for this property.
SimpleJsonSerializer.DEFAULT
.public ConfigBuilder serializer(Class<? extends WriterSerializer> value)
The serializer to use for serializing POJO values.
value
- The new value for this property.
SimpleJsonSerializer.DEFAULT
.public ConfigBuilder parser(ReaderParser value)
The parser to use for parsing values to POJOs.
value
- The new value for this property.
JsonParser.DEFAULT
.public ConfigBuilder parser(Class<? extends ReaderParser> value)
The parser to use for parsing values to POJOs.
value
- The new value for this property.
JsonParser.DEFAULT
.public ConfigBuilder encoder(ConfigEncoder value)
The encoder to use for encoding encoded configuration values.
value
- The new value for this property.
ConfigXorEncoder.INSTANCE
.public ConfigBuilder encoder(Class<? extends ConfigEncoder> value)
The encoder to use for encoding encoded configuration values.
value
- The new value for this property.
ConfigXorEncoder.INSTANCE
.public ConfigBuilder varResolver(VarResolver value)
The resolver to use for resolving SVL variables.
value
- The new value for this property.
VarResolver.DEFAULT
.public ConfigBuilder varResolver(Class<? extends VarResolver> value)
The resolver to use for resolving SVL variables.
value
- The new value for this property.
VarResolver.DEFAULT
.public ConfigBuilder binaryLineLength(int value)
When serializing binary values, lines will be split after this many characters.
Use
value
- The new value for this property.
public ConfigBuilder binaryFormat(BinaryFormat value)
The format to use when persisting byte arrays.
Possible values:
BinaryFormat.BASE64
- BASE64-encoded string.
BinaryFormat.HEX
- Hexadecimal.
BinaryFormat.SPACED_HEX
- Hexadecimal with spaces between bytes.
value
- The new value for this property.
BinaryFormat.BASE64
.public ConfigBuilder multiLineValuesOnSeparateLines()
When enabled, multi-line values will always be placed on a separate line from the key.
public ConfigBuilder readOnly()
When enabled, attempts to call any setters on this object will throw an UnsupportedOperationException
.
public ConfigBuilder add(Map<String,Object> properties)
ContextBuilder
Identical in function to ContextBuilder.set(String, Object)
but allows you to specify multiple values at once.
add
in class ContextBuilder
properties
- The properties to set on this class.
public ConfigBuilder addTo(String name, Object value)
ContextBuilder
SET properties are those properties with one of the following type parts:
For example, the BeanContext.BEAN_notBeanClasses
property which has the value
addTo
in class ContextBuilder
name
- The property name.value
- The new value to add to the SET property.
public ConfigBuilder appendTo(String name, Object value)
ContextBuilder
LIST properties are those properties with one of the following type parts:
For example, the BeanContext.BEAN_swaps
property which has the value
appendTo
in class ContextBuilder
name
- The property name.value
- The new value to add to the LIST property.
public ConfigBuilder apply(PropertyStore copyFrom)
ContextBuilder
apply
in class ContextBuilder
copyFrom
- The property store whose settings are being copied.public ConfigBuilder applyAnnotations(Class<?>... fromClasses)
ContextBuilder
Any annotations found that themselves are annotated with PropertyStoreApply
will be resolved and
applied as properties to this builder. These annotations include:
BeanConfig
CsvConfig
HtmlConfig
HtmlDocConfig
JsoConfig
JsonConfig
JsonSchemaConfig
MsgPackConfig
OpenApiConfig
ParserConfig
PlainTextConfig
SerializerConfig
SoapXmlConfig
UonConfig
UrlEncodingConfig
XmlConfig
Annotations on classes are appended in the following order:
The default var resolver VarResolver.DEFAULT
is used to resolve any variables in annotation field values.
applyAnnotations
in class ContextBuilder
fromClasses
- The classes on which the annotations are defined.public ConfigBuilder applyAnnotations(Method... fromMethods)
ContextBuilder
Any annotations found that themselves are annotated with PropertyStoreApply
will be resolved and
applied as properties to this builder. These annotations include:
BeanConfig
CsvConfig
HtmlConfig
HtmlDocConfig
JsoConfig
JsonConfig
JsonSchemaConfig
MsgPackConfig
OpenApiConfig
ParserConfig
PlainTextConfig
SerializerConfig
SoapXmlConfig
UonConfig
UrlEncodingConfig
XmlConfig
Annotations on methods are appended in the following order:
The default var resolver VarResolver.DEFAULT
is used to resolve any variables in annotation field values.
applyAnnotations
in class ContextBuilder
fromMethods
- The methods on which the annotations are defined.public ConfigBuilder applyAnnotations(AnnotationList al, VarResolverSession r)
ContextBuilder
The AnnotationList
object is an ordered list of annotations and the classes/methods/packages they were found on.
applyAnnotations
in class ContextBuilder
al
- The list of all annotations annotated with PropertyStoreApply
.r
- The string resolver for resolving variables in annotation values.public ConfigBuilder debug()
ContextBuilder
Enables the following additional information during serialization:
BeanTraverseContext.BEANTRAVERSE_detectRecursions
.
Enables the following additional information during parsing:
debug
in class ContextBuilder
public ConfigBuilder locale(Locale value)
ContextBuilder
Specifies the default locale for serializer and parser sessions when not specified via SessionArgs.locale(Locale)
.
Typically used for POJO swaps that need to deal with locales such as swaps that convert PojoSwap.swap(BeanSession, Object)
and
PojoSwap.unswap(BeanSession, Object, ClassMeta, String)
methods.
locale
in class ContextBuilder
value
- The new value for this property.public ConfigBuilder mediaType(MediaType value)
ContextBuilder
Specifies the default media type for serializer and parser sessions when not specified via SessionArgs.mediaType(MediaType)
.
Typically used for POJO swaps that need to serialize the same POJO classes differently depending on
the specific requested media type. For example, a swap could handle a request for media types
mediaType
in class ContextBuilder
value
- The new value for this property.public ConfigBuilder prependTo(String name, Object value)
ContextBuilder
LIST properties are those properties with one of the following type parts:
For example, the BeanContext.BEAN_swaps
property which has the value
prependTo
in class ContextBuilder
name
- The property name.value
- The new value to add to the LIST property.
public ConfigBuilder putAllTo(String name, Object value)
ContextBuilder
MAP properties are those properties with one of the following type parts:
For example, the BeanContext.BEAN_implClasses
property which has the value
putAllTo
in class ContextBuilder
name
- The property name.value
- Either a JSON Object string or a Map
whose valid value types depend on the property type:
public ConfigBuilder putTo(String name, String key, Object value)
ContextBuilder
MAP properties are those properties with one of the following type parts:
For example, the BeanContext.BEAN_implClasses
property which has the value
putTo
in class ContextBuilder
name
- The property name.key
- The property value map key.value
- The property value map value.
public ConfigBuilder removeFrom(String name, Object value)
ContextBuilder
removeFrom
in class ContextBuilder
name
- The property name.value
- The property value in the SET/LIST/MAP property.public ConfigBuilder set(Map<String,Object> properties)
ContextBuilder
Identical in function to ContextBuilder.set(String, Object)
but allows you to specify multiple values at once.
set
in class ContextBuilder
properties
- The properties to set on this class.
public ConfigBuilder set(String name, Object value)
ContextBuilder
Provides the ability to specify configuration property values in a generic fashion.
Property names must have the following format that identify their datatype...
...where the parts consist of the following...
For example,
Property values get 'normalized' when they get set.
For example, calling PropertyStore
class to be comparable
and useful in determining whether a cached instance of a context object can be returned.
As a general rule, builders don't typically have "unsetter" methods. For example, once you've set strict
mode on the
set
in class ContextBuilder
name
- The property name.value
- The property value.
public ConfigBuilder timeZone(TimeZone value)
ContextBuilder
Specifies the default time zone for serializer and parser sessions when not specified via SessionArgs.timeZone(TimeZone)
.
Typically used for POJO swaps that need to deal with timezones such as swaps that convert PojoSwap.swap(BeanSession, Object)
and
PojoSwap.unswap(BeanSession, Object, ClassMeta, String)
methods.
timeZone
in class ContextBuilder
value
- The new value for this property.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.