public abstract class YamlProcessor extends Object
Requires SnakeYAML 1.18 or higher, as of Spring Framework 5.0.6.
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | YamlProcessor.DocumentMatcherStrategy interface used to test if properties match. | 
| static interface  | YamlProcessor.MatchCallbackCallback interface used to process the YAML parsing results. | 
| static class  | YamlProcessor.MatchStatusStatus returned from  YamlProcessor.DocumentMatcher.matches(java.util.Properties). | 
| static class  | YamlProcessor.ResolutionMethodMethod to use for resolving resources. | 
| Constructor and Description | 
|---|
| YamlProcessor() | 
| Modifier and Type | Method and Description | 
|---|---|
| protected org.yaml.snakeyaml.Yaml | createYaml()Create the  Yamlinstance to use. | 
| protected Map<String,Object> | getFlattenedMap(Map<String,Object> source)Return a flattened version of the given map, recursively following any nested Map
 or Collection values. | 
| protected void | process(YamlProcessor.MatchCallback callback)Provide an opportunity for subclasses to process the Yaml parsed from the supplied
 resources. | 
| void | setDocumentMatchers(YamlProcessor.DocumentMatcher... matchers)A map of document matchers allowing callers to selectively use only
 some of the documents in a YAML resource. | 
| void | setMatchDefault(boolean matchDefault)Flag indicating that a document for which all the
  document matchersabstain will
 nevertheless match. | 
| void | setResolutionMethod(YamlProcessor.ResolutionMethod resolutionMethod)Method to use for resolving resources. | 
| void | setResources(org.springframework.core.io.Resource... resources)Set locations of YAML  resourcesto be loaded. | 
public void setDocumentMatchers(YamlProcessor.DocumentMatcher... matchers)
--- lines, and each document is converted
 to properties before the match is made. E.g.
 environment: dev url: https://dev.bar.com name: Developer Setup --- environment: prod url:https://foo.bar.com name: My Cool Appwhen mapped with
 setDocumentMatchers(properties ->
     ("prod".equals(properties.getProperty("environment")) ? MatchStatus.FOUND : MatchStatus.NOT_FOUND));
 
 would end up as
 environment=prod url=https://foo.bar.com name=My Cool App
public void setMatchDefault(boolean matchDefault)
document matchers abstain will
 nevertheless match. Default is true.public void setResolutionMethod(YamlProcessor.ResolutionMethod resolutionMethod)
YamlProcessor.ResolutionMethod.OVERRIDE.public void setResources(org.springframework.core.io.Resource... resources)
resources to be loaded.YamlProcessor.ResolutionMethodprotected void process(YamlProcessor.MatchCallback callback)
matchers. If a document
 matches it is passed into the callback, along with its representation as Properties.
 Depending on the setResolutionMethod(ResolutionMethod) not all of the
 documents will be parsed.callback - a callback to delegate to once matching documents are foundcreateYaml()protected org.yaml.snakeyaml.Yaml createYaml()
Yaml instance to use.
 The default implementation sets the "allowDuplicateKeys" flag to false,
 enabling built-in duplicate key handling in SnakeYAML 1.18+.
LoaderOptions.setAllowDuplicateKeys(boolean)protected final Map<String,Object> getFlattenedMap(Map<String,Object> source)
YamlProcessor.MatchCallback the result will
 contain the same values as the YamlProcessor.MatchCallback Properties.source - the source map