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

ENH: conditional required annotation for schema #5109

Merged

Conversation

chenqi0805
Copy link
Collaborator

Description

This PR

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
@@ -20,6 +21,16 @@
import java.util.Locale;
import java.time.format.DateTimeFormatter;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "match", value = "null")},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Having a static import for @ConditionalRequired.SchemaProperty probably will make this statement more easy to read

@ConditionalRequired.IfThenElse(
ifFulfilled = {
@ConditionalRequired.SchemaProperty(field = "format", value = "null"),
@ConditionalRequired.SchemaProperty(field = "value_expression", value = "null"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to express OR releation when there are more than one condition grouped under ifFulfilled

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For OR relation we have to use separate IfThenElse annotation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goit 👍

Signed-off-by: George Chen <[email protected]>
@chenqi0805 chenqi0805 merged commit 56cc569 into opensearch-project:main Oct 28, 2024
46 of 47 checks passed
@chenqi0805 chenqi0805 deleted the enh/conditional-required-schema branch October 28, 2024 20:13

@ConditionalRequired(value = {
@IfThenElse(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a test for this annotation.

import org.opensearch.dataprepper.model.event.EventKey;

import java.util.List;

@ConditionalRequired(value = {
@IfThenElse(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a test for this annotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants