Class YamlProcessor

    • Method Detail

      • setDocumentMatchers

        public void setDocumentMatchers​(YamlProcessor.DocumentMatcher... matchers)
        A map of document matchers allowing callers to selectively use only some of the documents in a YAML resource. In YAML documents are separated by --- 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 App
         
        when 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
         
      • setMatchDefault

        public void setMatchDefault​(boolean matchDefault)
        Flag indicating that a document for which all the document matchers abstain will nevertheless match. Default is true.
      • process

        protected void process​(YamlProcessor.MatchCallback callback)
        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 the 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.
        Parameters:
        callback - a callback to delegate to once matching documents are found
        See Also:
        createYaml()
      • createYaml

        protected org.yaml.snakeyaml.Yaml createYaml()
        Create the Yaml instance to use.