Skip to content

Commit

Permalink
MAINT: simplify reference
Browse files Browse the repository at this point in the history
Signed-off-by: George Chen <[email protected]>
  • Loading branch information
chenqi0805 committed Oct 28, 2024
1 parent 6d04060 commit 53be872
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import jakarta.validation.constraints.AssertTrue;
import org.opensearch.dataprepper.model.annotations.AlsoRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty;
import org.opensearch.dataprepper.model.annotations.ExampleValues;
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example;

Expand All @@ -22,13 +24,13 @@
import java.time.format.DateTimeFormatter;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "match", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "from_time_received", value = "true")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "match", value = "null")},
thenExpect = {@SchemaProperty(field = "from_time_received", value = "true")}
),
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "from_time_received", value = "false")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "match")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "from_time_received", value = "false")},
thenExpect = {@SchemaProperty(field = "match")}
)
})
@JsonPropertyOrder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,41 @@
import jakarta.validation.constraints.NotNull;
import org.opensearch.dataprepper.model.annotations.AlsoRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty;

import java.util.List;
import java.util.stream.Stream;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "key", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "metadata_key")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "key", value = "null")},
thenExpect = {@SchemaProperty(field = "metadata_key")}
),
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "metadata_key", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "key")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "metadata_key", value = "null")},
thenExpect = {@SchemaProperty(field = "key")}
),
@ConditionalRequired.IfThenElse(
@IfThenElse(
ifFulfilled = {
@ConditionalRequired.SchemaProperty(field = "format", value = "null"),
@ConditionalRequired.SchemaProperty(field = "value", value = "null"),
@SchemaProperty(field = "format", value = "null"),
@SchemaProperty(field = "value", value = "null"),
},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "value_expression")}
thenExpect = {@SchemaProperty(field = "value_expression")}
),
@ConditionalRequired.IfThenElse(
@IfThenElse(
ifFulfilled = {
@ConditionalRequired.SchemaProperty(field = "format", value = "null"),
@ConditionalRequired.SchemaProperty(field = "value_expression", value = "null"),
@SchemaProperty(field = "format", value = "null"),
@SchemaProperty(field = "value_expression", value = "null"),
},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "value")}
thenExpect = {@SchemaProperty(field = "value")}
),
@ConditionalRequired.IfThenElse(
@IfThenElse(
ifFulfilled = {
@ConditionalRequired.SchemaProperty(field = "value", value = "null"),
@ConditionalRequired.SchemaProperty(field = "value_expression", value = "null"),
@SchemaProperty(field = "value", value = "null"),
@SchemaProperty(field = "value_expression", value = "null"),
},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "format")}
thenExpect = {@SchemaProperty(field = "format")}
)
})
@JsonPropertyOrder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import org.opensearch.dataprepper.model.annotations.AlsoRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty;
import org.opensearch.dataprepper.typeconverter.ConverterArguments;

import java.util.List;
import java.util.Optional;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "key", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "keys")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "key", value = "null")},
thenExpect = {@SchemaProperty(field = "keys")}
),
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "keys", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "key")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "keys", value = "null")},
thenExpect = {@SchemaProperty(field = "key")}
)
})
@JsonPropertyOrder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "use_source_key", value = "false")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "key")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "use_source_key", value = "false")},
thenExpect = {@SchemaProperty(field = "key")}
)
})
@JsonPropertyOrder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
import jakarta.validation.constraints.Size;
import org.opensearch.dataprepper.model.annotations.AlsoRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty;
import org.opensearch.dataprepper.model.event.EventKey;

import java.util.List;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "delimiter", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "delimiter_regex")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "delimiter", value = "null")},
thenExpect = {@SchemaProperty(field = "delimiter_regex")}
),
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "delimiter_regex", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "delimiter")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "delimiter_regex", value = "null")},
thenExpect = {@SchemaProperty(field = "delimiter")}
)
})
@JsonPropertyOrder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
import jakarta.validation.constraints.Size;
import org.opensearch.dataprepper.model.annotations.AlsoRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse;
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty;

@ConditionalRequired(value = {
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "delimiter", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "delimiter_regex")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "delimiter", value = "null")},
thenExpect = {@SchemaProperty(field = "delimiter_regex")}
),
@ConditionalRequired.IfThenElse(
ifFulfilled = {@ConditionalRequired.SchemaProperty(field = "delimiter_regex", value = "null")},
thenExpect = {@ConditionalRequired.SchemaProperty(field = "delimiter")}
@IfThenElse(
ifFulfilled = {@SchemaProperty(field = "delimiter_regex", value = "null")},
thenExpect = {@SchemaProperty(field = "delimiter")}
)
})
@JsonPropertyOrder
Expand Down

0 comments on commit 53be872

Please sign in to comment.