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
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:
-
Nested Class Summary
Nested ClassesNested 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
FieldsFields 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
ConstructorsConstructorDescriptionFor 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
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, getPropertyUtils, getSingleData, isAllowDuplicateKeys, isEnumCaseSensitive, isExplicitPropertyUtils, isWrappedToRootException, newInstance, newInstance, newInstance, newList, newMap, newSet, postponeMapFilling, postponeSetFilling, setAllowDuplicateKeys, setComposer, setEnumCaseSensitive, setPropertyUtils, setWrappedToRootException
-
Field Details
-
ENV_TAG
-
ENV_FORMAT
-
-
Constructor Details
-
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 Details
-
apply
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
-
getEnv
Get value of the environment variable- Parameters:
key
- - the name of the variable- Returns:
- value or null if not set
-