KEYCLOAK-3618: Extensible ResourceType for provider-created AdminEvents #3316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The implementation is based on the extensible enum pattern. It requires that the enum implement an interface (an empty one in our case).
There were two options for refactoring:
leave
ResourceType
as is, introduceIResourceType
:public enum ResourceType implements IResourceType
This mostly requires changes to imports and method signatures (about 20 code locations), but introduces that ugly
IResourceType
.ResourceType
enum fields are referenced just like before, withResourceType.of("FOO")
used to obtain custom value;make
ResourceType
interface, renameResourceType
to something likeStandardResourceType
:public enum StandardResourceType implements ResourceType
This would require changes to all the enum field references (~100 locations).
I've implemented the first variant because of its relative simplicity. Please let me know if the second variant is preferable, I'll reimplement the PR.