forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: conditional required annotation for schema (opensearch-project#5109
) * MAINT: conditional required schema Signed-off-by: George Chen <[email protected]>
- Loading branch information
1 parent
1dadd9e
commit 56cc569
Showing
9 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...r-api/src/main/java/org/opensearch/dataprepper/model/annotations/ConditionalRequired.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,50 @@ | ||
package org.opensearch.dataprepper.model.annotations; | ||
|
||
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 if-then-else requirements. | ||
*/ | ||
@Target({ ElementType.FIELD, ElementType.TYPE }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ConditionalRequired { | ||
/** | ||
* Array of if-then-else requirements. | ||
*/ | ||
IfThenElse[] value(); | ||
|
||
/** | ||
* Annotation to represent an if-then-else requirement. | ||
*/ | ||
@interface IfThenElse { | ||
/** | ||
* Array of property schemas involved in if condition. | ||
*/ | ||
SchemaProperty[] ifFulfilled(); | ||
/** | ||
* Array of property schemas involved in then expectation. | ||
*/ | ||
SchemaProperty[] thenExpect(); | ||
/** | ||
* Array of property schemas involved in else expectation. | ||
*/ | ||
SchemaProperty[] elseExpect() default {}; | ||
} | ||
|
||
/** | ||
* Annotation to represent a property schema. | ||
*/ | ||
@interface SchemaProperty { | ||
/** | ||
* Name of the property. | ||
*/ | ||
String field(); | ||
/** | ||
* Value of the property. Empty string means any non-null value is allowed. | ||
*/ | ||
String value() 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
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
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.