Package org.yaml.snakeyaml.env
Class EnvScalarConstructor
- java.lang.Object
-
- org.yaml.snakeyaml.constructor.BaseConstructor
-
- org.yaml.snakeyaml.constructor.SafeConstructor
-
- org.yaml.snakeyaml.constructor.Constructor
-
- org.yaml.snakeyaml.env.EnvScalarConstructor
-
public class EnvScalarConstructor extends Constructor
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 Class Summary
-
Nested classes/interfaces inherited from class org.yaml.snakeyaml.constructor.Constructor
Constructor.ConstructMapping, Constructor.ConstructScalar, Constructor.ConstructSequence, Constructor.ConstructYamlObject
-
Nested classes/interfaces inherited from class org.yaml.snakeyaml.constructor.SafeConstructor
SafeConstructor.ConstructUndefined, SafeConstructor.ConstructYamlBinary, SafeConstructor.ConstructYamlBool, SafeConstructor.ConstructYamlFloat, SafeConstructor.ConstructYamlInt, SafeConstructor.ConstructYamlMap, SafeConstructor.ConstructYamlNull, SafeConstructor.ConstructYamlOmap, SafeConstructor.ConstructYamlPairs, SafeConstructor.ConstructYamlSeq, SafeConstructor.ConstructYamlSet, SafeConstructor.ConstructYamlStr, SafeConstructor.ConstructYamlTimestamp
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
ENV_FORMAT
name must be a word ⇒ \w+ value can be any non-space ⇒ \S+static Tag
ENV_TAG
Tag to indicate ENV-
Fields inherited from class org.yaml.snakeyaml.constructor.SafeConstructor
undefinedConstructor
-
Fields inherited from class org.yaml.snakeyaml.constructor.BaseConstructor
composer, loadingConfig, NOT_INSTANTIATED_OBJECT, rootTag, typeDefinitions, typeTags, yamlClassConstructors, yamlConstructors, yamlMultiConstructors
-
-
Constructor Summary
Constructors Constructor Description EnvScalarConstructor()
For simple cases when no JavaBeans are neededEnvScalarConstructor(TypeDescription theRoot, Collection<TypeDescription> moreTDs, LoaderOptions loadingConfig)
Create EnvScalarConstructor which can create JavaBeans with variable substitution
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
apply(String name, String separator, String value, String environment)
Implement the logic for missing and unset variablesString
getEnv(String key)
Get value of the environment variable-
Methods inherited from class org.yaml.snakeyaml.constructor.Constructor
getClassForName, getClassForNode
-
Methods inherited from class org.yaml.snakeyaml.constructor.SafeConstructor
constructMapping2ndStep, constructSet2ndStep, createLongOrBigInteger, flattenMapping, flattenMapping, processDuplicateKeys, processDuplicateKeys
-
Methods inherited from class org.yaml.snakeyaml.constructor.BaseConstructor
addTypeDescription, checkData, constructArray, constructArrayStep2, constructDocument, constructMapping, constructObject, constructObjectNoCheck, constructScalar, constructSequence, constructSequenceStep2, constructSet, constructSet, createArray, createDefaultList, createDefaultMap, createDefaultSet, finalizeConstruction, getConstructor, getData, getLoadingConfig, getPropertyUtils, getSingleData, isAllowDuplicateKeys, isEnumCaseSensitive, isExplicitPropertyUtils, isWrappedToRootException, newInstance, newInstance, newInstance, newList, newMap, newSet, postponeMapFilling, postponeSetFilling, setAllowDuplicateKeys, setComposer, setEnumCaseSensitive, setPropertyUtils, setWrappedToRootException
-
-
-
-
Constructor Detail
-
EnvScalarConstructor
public EnvScalarConstructor()
For simple cases when no JavaBeans are needed
-
EnvScalarConstructor
public EnvScalarConstructor(TypeDescription theRoot, Collection<TypeDescription> moreTDs, LoaderOptions loadingConfig)
Create EnvScalarConstructor which can create JavaBeans with variable substitution- Parameters:
theRoot
- - the class (usually JavaBean) to be constructedmoreTDs
- - collection of classes used by the root classloadingConfig
- - configuration
-
-
Method Detail
-
apply
public String apply(String name, String separator, String value, String environment)
Implement the logic for missing and unset variables- Parameters:
name
- - variable name in the templateseparator
- - separator in the template, can be :-, -, :?, ?value
- - default value or the error in the templateenvironment
- - the value from environment for the provided variable- Returns:
- the value to apply in the template
-
-