-
Notifications
You must be signed in to change notification settings - Fork 202
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
ENH: introduce conditional annotation for schema generation #4934
Merged
chenqi0805
merged 8 commits into
opensearch-project:main
from
chenqi0805:enh/introduce-conditional-annotation-for-schema-generation
Oct 11, 2024
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f670a20
ENH: introduce conditional annotation for schema generation
chenqi0805 f624fd8
REF: annotation package
chenqi0805 5d85837
REF: annotation
chenqi0805 c7f5b4e
MAINT: missed class
chenqi0805 9a00ecb
MAINT: unused import
chenqi0805 5edb2ad
Update data-prepper-api/src/main/java/org/opensearch/dataprepper/mode…
chenqi0805 9ca202b
MAINT: merge main and resolve conflict
chenqi0805 b85501e
REF: rename annotation
chenqi0805 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...-prepper-api/src/main/java/org/opensearch/dataprepper/model/annotations/AlsoRequires.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.opensearch.dataprepper.model.annotations; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotation used in schema generation to define the names and corresponding values of other required | ||
* configurations if the configuration represented by the annotated field/method is present. | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.METHOD}) | ||
public @interface AlsoRequires { | ||
/** | ||
* Array of Required annotations, each representing a required property with its allowed values. | ||
*/ | ||
Required[] values(); | ||
} |
22 changes: 22 additions & 0 deletions
22
data-prepper-api/src/main/java/org/opensearch/dataprepper/model/annotations/Required.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.opensearch.dataprepper.model.annotations; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
/** | ||
* Annotation to represent a required property and its allowed values. | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Required { | ||
/** | ||
* Name of the required property. | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* Allowed values for the required property. The default value of {} means any non-null value is allowed. | ||
*/ | ||
String[] allowedValues() default {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the context clearer. Here are two options.
AlsoRequires
@AlsoRequired
.I think I like option 1.