Top Description Inners Fields Constructors Methods
org.yaml.snakeyaml.env

public Class EnvScalarConstructor

extends Constructor
Class Inheritance
Imports
java.util.Collection, java.util.regex.Matcher, .Pattern, org.yaml.snakeyaml.LoaderOptions, .TypeDescription, org.yaml.snakeyaml.constructor.AbstractConstruct, .Constructor, org.yaml.snakeyaml.error.MissingEnvironmentVariableException, org.yaml.snakeyaml.nodes.Node, .ScalarNode, .Tag

Construct scalar for format ${VARIABLE} replacing the template with the value from environment. It can also be used to create JavaBeans when the all the arguments are provided.
See Also
Variable substitution, Variable substitution

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
public static final Pattern
ENV_FORMAT

name must be a word ⇒ \w+ value can be any non-space ⇒ \S+

public static final Tag
ENV_TAG

Tag to indicate ENV

Constructor Summary

AccessConstructor and Description
public
EnvScalarConstructor()

For simple cases when no JavaBeans are needed

public
EnvScalarConstructor(TypeDescription
- the class (usually JavaBean) to be constructed
theRoot
,
Collection<TypeDescription>
- collection of classes used by the root class
moreTDs
,
LoaderOptions
- configuration
loadingConfig
)

Create EnvScalarConstructor which can create JavaBeans with variable substitution

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the value to apply in the template
apply
(String
- variable name in the template
name
,
String
- separator in the template, can be :-, -, :?, ?
separator
,
String
- default value or the error in the template
value
,
String
- the value from environment for the provided variable
environment
)

Implement the logic for missing and unset variables

public String

Returns:

value or null if not set
getEnv
(String
- the name of the variable
key
)

Get value of the environment variable

Inherited from org.yaml.snakeyaml.constructor.Constructor:
getClassForNamegetClassForNode

Field Detail

ENV_FORMATback to summary
public static final Pattern ENV_FORMAT

name must be a word ⇒ \w+ value can be any non-space ⇒ \S+

ENV_TAGback to summary
public static final Tag ENV_TAG

Tag to indicate ENV

Constructor Detail

EnvScalarConstructorback to summary
public EnvScalarConstructor()

For simple cases when no JavaBeans are needed

EnvScalarConstructorback to summary
public EnvScalarConstructor(TypeDescription theRoot, Collection<TypeDescription> moreTDs, LoaderOptions loadingConfig)

Create EnvScalarConstructor which can create JavaBeans with variable substitution

Parameters
theRoot:TypeDescription

- the class (usually JavaBean) to be constructed

moreTDs:Collection<TypeDescription>

- collection of classes used by the root class

loadingConfig:LoaderOptions

- configuration

Method Detail

applyback to summary
public String apply(String name, String separator, String value, String environment)

Implement the logic for missing and unset variables

Parameters
name:String

- variable name in the template

separator:String

- separator in the template, can be :-, -, :?, ?

value:String

- default value or the error in the template

environment:String

- the value from environment for the provided variable

Returns:String

the value to apply in the template

getEnvback to summary
public String getEnv(String key)

Get value of the environment variable

Parameters
key:String

- the name of the variable

Returns:String

value or null if not set

org.yaml.snakeyaml.env back to summary

private Class EnvScalarConstructor.ConstructEnv

extends AbstractConstruct
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Object
construct(Node
composed Node
node
)

Implements org.yaml.snakeyaml.constructor.Construct.construct.

Construct a Java instance with all the properties injected when it is possible.
Inherited from org.yaml.snakeyaml.constructor.AbstractConstruct:
construct2ndStep

Constructor Detail

ConstructEnvback to summary
private ConstructEnv()

Method Detail

constructback to summary
public Object construct(Node node)

Implements org.yaml.snakeyaml.constructor.Construct.construct.

Doc from org.yaml.snakeyaml.constructor.Construct.construct.

Construct a Java instance with all the properties injected when it is possible.

Parameters
node:Node

composed Node

Returns:Object

a complete Java instance