Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let, LetMany Variable Support #440

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lopezton-anthem
Copy link
Contributor

@lopezton-anthem lopezton-anthem commented Mar 18, 2019

Description

Adding @Let support, a mechanism for providing resolved values for provided keywords within an execution context.

// static value replacement
@Let(name = "foo", value = "/configVariables/p0")
@Config(url = "<!foo!>/_process?fn=_set&value=p1-did-it")
private String p1;

// param path resolver replacement (using reserved keyword) + transitivity
@Let(name = "bar", value = "<!#this!>/../p0")
@Let(name = "baz", value = "p2-did-it")
@Config(url = "<!bar!>/_process?fn=_set&value=<!baz!>")
private String p2;

// spel expression replacement
@Let(name = "foo", spel = "LocalDateTime.now()")
@Config(url = "<!#this!>/../date/_process?fn=_set&value=<!foo!>")
private String p3;

Overview of Changes

  • Refactored DefaultCommandPathVariableResolver to use Resolver interfaces for resolver implementations.
    • The names of the "reserved keywords" are now maintained by ReservedKeywordRegistry, which is used to ensure @Let does not allow for overriding "reserved keywords" (like #this, #self, etc.)
    • Custom resolvers can be registered via DefaultCommandPathVariableResolver.registerResolver(Resolver resolver) if needed.
  • Introduced @Let and @LetMany to resolve values within an ExecutionContext
    • value - static values
    • spel - spel expression
  • Added a resolvedVariableMap to ExecutionContext to maintain the resolved variables during the execution process.

Type of Change

  • New feature
  • Refactor/Technical Debt
  • This change requires a documentation update

Test Details

  • DefaultConfigVariableResolverTest

Additional Notes

N/A

@openanthem-admin
Copy link
Contributor

You did it @lopezton-anthem!

Thank you for signing the Anthem Opensource Software CLA.

@lopezton-anthem
Copy link
Contributor Author

This feature is an experimental feature I thought up while trying to dream up "helpful" features. I don't know if it will have a high use case, but I've seen a lot of hard-to-read @Config statements so I thought I'd take this up in some spare time.

@lopezton-anthem lopezton-anthem changed the title ConfigPlaceholders Let, LetMany Variable Support Mar 26, 2019
@lopezton-anthem
Copy link
Contributor Author

@soham-anthem Thoughts on using resolvedVariableMap in ExecutionContext for this? My only concern is the need to clear the maps once the execution has finished to give up the object references.

@openanthem-admin
Copy link
Contributor

You did it @lopezton-anthem!

Thank you for signing the Anthem Opensource Software CLA.

@lopezton-anthem lopezton-anthem changed the base branch from 2.0.x to master August 7, 2019 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants