Class ExpressionSupport
java.lang.Object
org.chenile.cconfig.util.ExpressionSupport
Use this class if you have a list of Cconfigs which need to manipulate an existing set of keys.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate static final ObjectMapperprivate static final ExpressionParser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidAdd all keys from cconfigList whose path is null to the key list.static voidprivate static Objectprivate static StringConvert the path expression from form "a.b.c" to ['a']['b']['c'] as supported by SPEL for maps.private static ObjectParses the string as JSON if applicable and returns the parsed string as mapprivate static Objectprivate static voidFor every key from JSON make sure that you override it if there are records available in the cconfig
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
objectMapper
-
parser
-
-
Constructor Details
-
ExpressionSupport
public ExpressionSupport()
-
-
Method Details
-
augmentKeys
-
addMissingKeys
Add all keys from cconfigList whose path is null to the key list. They might have been defined for the first time or perhaps they might have been redefined in the config retriever. Add only the keys that are missing in the key list.(i.e. keys defined for the first time in the cconfig and are not present in the key list)- Parameters:
keys- - the existing set of keys that will be augmented.cconfigList- - the list of all cconfigs. This will manipulate the keys
-
overrideKeys
-
override
- Parameters:
key- the keyvalue- the original value either from JSON or from the first record found with path null in DBconfigList- the list of all keys obtained for the module and the custom attribute.- Returns:
- the modified value after all the operations in dblist are applied against the key
-
mapExpression
Convert the path expression from form "a.b.c" to ['a']['b']['c'] as supported by SPEL for maps. Note that even if expression contains indexes this handles it. Example: a.0.xyz becomes ['a']['0']['xyz']- Parameters:
p- the path defined in the database- Returns:
- the expression in a form that is amenable to be used as a SPEL expression for maps
-
evaluate
- Parameters:
key- the keypath- the path in the value that has been modified to a new valuevalue- the original value that will be modifieddbValue- the db value that will be applied against the original record- Returns:
- the modified value after SPEL constructs specified in the path are invoked on the original record
-
objectify
-