Package com.elo.gradle.osgi.utils
Class VariableReplacer
java.lang.Object
com.elo.gradle.osgi.utils.VariableReplacer
Utility class to replace variables in strings
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final recordRepresents a variable expression in the format ${variable:defaultValue~>func} -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidregisterFunction(String name, UnaryOperator<String> function) Registers a templating functionstatic StringreplaceVariable(String expression, Map<String, ?> properties) Replaces a variable in a string.
-
Method Details
-
replaceVariable
Replaces a variable in a string. A variable looks like this: ${variable:defaultValue} If a value for this variable is found in the Properties object, this value is prioritised.- Parameters:
expression- the stringproperties- the properties object- Returns:
- the adjusted string
-
registerFunction
Registers a templating function- Parameters:
name- the name of the functionfunction- the function to register
-