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

Add "FieldResolverStrategies" utility/factory class #279

Closed
sleberknight opened this issue Apr 1, 2024 · 0 comments · Fixed by #282
Closed

Add "FieldResolverStrategies" utility/factory class #279

sleberknight opened this issue Apr 1, 2024 · 0 comments · Fixed by #282
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

sleberknight commented Apr 1, 2024

TestHelpers contains a bunch of useful methods to easily create FieldResolverStrategy instances for a single resolution, e.g., for a specific value, or using a Supplier. Recently I've wanted a few of these in production code. So, create a new utility/factory class that contains methods to easily create instances when you only want a single strategy.

It could be named FieldResolverStrategies and provide all or only a few of methods that exist in TestHelpers currently. Here are the signatures from TestHelpers:

<T> FieldResolverStrategy<T> newSystemPropertyFieldResolverStrategy(String systemPropertyKey)

<T> FieldResolverStrategy<T> newEnvVarFieldResolverStrategy(String envVariable)

<T> FieldResolverStrategy<T> newExternalPropertyFieldResolverStrategy(String externalProperty)

<T> FieldResolverStrategy<T> newExplicitValueFieldResolverStrategy(T explicitValue)

<T> FieldResolverStrategy<T> newSupplierFieldResolverStrategy(Supplier<T> supplier)

The only one I've needed thus far in production code is for an explicit value, so maybe we start with only that method and add others if needed. We should check if one or more of these is already used in existing ConfigProvider implementations, and those are good candidates to include as well.

@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Apr 1, 2024
@sleberknight sleberknight added this to the 2.3.0 milestone Apr 1, 2024
@sleberknight sleberknight self-assigned this Apr 1, 2024
sleberknight added a commit that referenced this issue Apr 3, 2024
* Moved the existing implementations from TestHelpers
* Add a test (even though they are indirectly tested as well)

Closes #279
chrisrohr pushed a commit that referenced this issue Apr 3, 2024
* Moved the existing implementations from TestHelpers
* Add a test (even though they are indirectly tested as well)

Closes #279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant