Module org.github.gestalt.core
Class TransformerPostProcessor
- java.lang.Object
-
- org.github.gestalt.config.post.process.transform.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_HOMESo 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 Summary
Fields Modifier and Type Field Description static java.lang.StringdefaultSubstitutionRegex
-
Constructor Summary
Constructors Constructor Description TransformerPostProcessor()By default, use the service loader to load all Transformer classes.TransformerPostProcessor(java.util.List<Transformer> transformers)Creates a TransformerPostProcessor with a list of transformers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyConfig(PostProcessorConfig config)Apply the PostProcessorConfig to the Post Processor.GResultOf<ConfigNode>process(java.lang.String path, ConfigNode currentNode)run the post process the current node.
-
-
-
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:PostProcessorApply 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:
applyConfigin interfacePostProcessor- Parameters:
config- GestaltConfig to update the Post Processor
-
process
public GResultOf<ConfigNode> process(java.lang.String path, ConfigNode currentNode)
Description copied from interface:PostProcessorrun the post process the current node.- Specified by:
processin interfacePostProcessor- Parameters:
path- current pathcurrentNode- current node to post process.- Returns:
- the node after running though the post processor.
-
-