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

Library: Half-open Enumeration pattern #5

Open
stijn-dejongh opened this issue Sep 25, 2024 · 0 comments
Open

Library: Half-open Enumeration pattern #5

stijn-dejongh opened this issue Sep 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@stijn-dejongh
Copy link
Member

Outline

Combine the type safety and determinism of enumerations with the runtype/deploy time extensibility offered by configuration files. A half-open enumeration type will first look through it's predefined (in-code) specifications, and add a new type object in case the requested type is not available.

Usage desiderata

Should read similarly to the Optional class in java enumFor(String name).orElse(EnumClass::create).

Implementation Notes

  • This is basically a constrained Factory Class pattern on top of predefined enumerations.
  • There should be an option to configure the factory to only allow the creation of new Type-objects if they adhere to certain conditions ( e.g. "exist in database", "are listed in config file", "contain certain words" )
@stijn-dejongh stijn-dejongh added the enhancement New feature or request label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant