Class TransformerPostProcessor

  • All Implemented Interfaces:
    PostProcessor

    public final class TransformerPostProcessor
    extends java.lang.Object
    implements PostProcessor
    A Post Processor used to replace leaf values that have the format ${transform:key} with a new value. The transform represents the source of the data, such as envVar for Environment Variables. The Key is how we look up the data in the data source, such as an Environment Variable JAVA_HOME

    So you could have a leaf value "hello ${envVar:USER_NAME} you are level ${envVar:USER_LEVEL}!" where USER_NAME=john and USER_LEVEL=6, will get transformed into "hello john you are level 6!"

    You do not need to specify the transform name, so it will search for the value in all default transformers based on priority. It will then return the first value found. So in the above example you can also use "hello ${USER_NAME} you are level ${USER_LEVEL}!" and it will find the values in the Env Vars.

    • Field Detail

      • defaultSubstitutionRegex

        public static final java.lang.String defaultSubstitutionRegex
        See Also:
        Constant Field Values
    • Constructor Detail

      • TransformerPostProcessor

        public TransformerPostProcessor()
        By default, use the service loader to load all Transformer classes.
      • TransformerPostProcessor

        public TransformerPostProcessor​(java.util.List<Transformer> transformers)
        Creates a TransformerPostProcessor with a list of transformers.
        Parameters:
        transformers - list of transformers to use
    • Method Detail

      • applyConfig

        public void applyConfig​(PostProcessorConfig config)
        Description copied from interface: PostProcessor
        Apply the PostProcessorConfig to the Post Processor. Needed when building via the ServiceLoader It is a default method as most Post Processor don't need to apply configs.
        Specified by:
        applyConfig in interface PostProcessor
        Parameters:
        config - GestaltConfig to update the Post Processor
      • process

        public GResultOf<ConfigNode> process​(java.lang.String path,
                                             ConfigNode currentNode)
        Description copied from interface: PostProcessor
        run the post process the current node.
        Specified by:
        process in interface PostProcessor
        Parameters:
        path - current path
        currentNode - current node to post process.
        Returns:
        the node after running though the post processor.