|
|
@ -42,7 +42,7 @@ import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Base class for Yaml factories. |
|
|
|
* Base class for YAML factories. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Dave Syer |
|
|
|
* @author Dave Syer |
|
|
|
* @since 4.1 |
|
|
|
* @since 4.1 |
|
|
@ -65,7 +65,6 @@ public abstract class YamlProcessor { |
|
|
|
* some of the documents in a YAML resource. In YAML documents are |
|
|
|
* some of the documents in a YAML resource. In YAML documents are |
|
|
|
* separated by <code>---<code> lines, and each document is converted |
|
|
|
* separated by <code>---<code> lines, and each document is converted |
|
|
|
* to properties before the match is made. E.g. |
|
|
|
* to properties before the match is made. E.g. |
|
|
|
* |
|
|
|
|
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* environment: dev |
|
|
|
* environment: dev |
|
|
|
* url: http://dev.bar.com
|
|
|
|
* url: http://dev.bar.com
|
|
|
@ -75,11 +74,9 @@ public abstract class YamlProcessor { |
|
|
|
* url:http://foo.bar.com
|
|
|
|
* url:http://foo.bar.com
|
|
|
|
* name: My Cool App |
|
|
|
* name: My Cool App |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
|
|
|
|
* when mapped with |
|
|
|
* when mapped with |
|
|
|
* <code>documentMatchers = YamlProcessor.mapMatcher({"environment": "prod"})</code> |
|
|
|
* <code>documentMatchers = YamlProcessor.mapMatcher({"environment": "prod"})</code> |
|
|
|
* would end up as |
|
|
|
* would end up as |
|
|
|
* |
|
|
|
|
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* environment=prod |
|
|
|
* environment=prod |
|
|
|
* url=http://foo.bar.com
|
|
|
|
* url=http://foo.bar.com
|
|
|
@ -103,9 +100,9 @@ public abstract class YamlProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Method to use for resolving resources. Each resource will be converted to a Map, so |
|
|
|
* Method to use for resolving resources. Each resource will be converted to a Map, |
|
|
|
* this property is used to decide which map entries to keep in the final output from |
|
|
|
* so this property is used to decide which map entries to keep in the final output |
|
|
|
* this factory. |
|
|
|
* from this factory. |
|
|
|
* @param resolutionMethod the resolution method to set (defaults to |
|
|
|
* @param resolutionMethod the resolution method to set (defaults to |
|
|
|
* {@link ResolutionMethod#OVERRIDE}). |
|
|
|
* {@link ResolutionMethod#OVERRIDE}). |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -127,9 +124,9 @@ public abstract class YamlProcessor { |
|
|
|
* Provide an opportunity for subclasses to process the Yaml parsed from the supplied |
|
|
|
* Provide an opportunity for subclasses to process the Yaml parsed from the supplied |
|
|
|
* resources. Each resource is parsed in turn and the documents inside checked against |
|
|
|
* resources. Each resource is parsed in turn and the documents inside checked against |
|
|
|
* the {@link #setDocumentMatchers(DocumentMatcher...) matchers}. If a document |
|
|
|
* the {@link #setDocumentMatchers(DocumentMatcher...) matchers}. If a document |
|
|
|
* matches it is passed into the callback, along with its representation as |
|
|
|
* matches it is passed into the callback, along with its representation as Properties. |
|
|
|
* Properties. Depending on the {@link #setResolutionMethod(ResolutionMethod)} not all |
|
|
|
* Depending on the {@link #setResolutionMethod(ResolutionMethod)} not all of the |
|
|
|
* of the documents will be parsed. |
|
|
|
* documents will be parsed. |
|
|
|
* @param callback a callback to delegate to once matching documents are found |
|
|
|
* @param callback a callback to delegate to once matching documents are found |
|
|
|
* @see #createYaml() |
|
|
|
* @see #createYaml() |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -393,6 +390,11 @@ public abstract class YamlProcessor { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected static class StrictMapAppenderConstructor extends Constructor { |
|
|
|
protected static class StrictMapAppenderConstructor extends Constructor { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Declared as public for use in subclasses
|
|
|
|
|
|
|
|
public StrictMapAppenderConstructor() { |
|
|
|
|
|
|
|
super(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Map<Object, Object> constructMapping(MappingNode node) { |
|
|
|
protected Map<Object, Object> constructMapping(MappingNode node) { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -421,7 +423,6 @@ public abstract class YamlProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|