Skip to content

Commit

Permalink
Import ExampleValues.Example to simplify the annotation usage in Date…
Browse files Browse the repository at this point in the history
…ProcessorConfig.

Signed-off-by: David Venable <dlv@amazon.com>
  • Loading branch information
dlvenable committed Oct 23, 2024
1 parent 5440445 commit d3faea7
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jakarta.validation.constraints.AssertTrue;
import org.opensearch.dataprepper.model.annotations.AlsoRequired;
import org.opensearch.dataprepper.model.annotations.ExampleValues;
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example;

import java.time.ZoneId;
import java.util.List;
Expand Down Expand Up @@ -49,9 +50,9 @@ public static class DateMatch {
"which represent the timestamp as the number of seconds, milliseconds, and nanoseconds since the epoch. " +
"Epoch values always use the UTC time zone.")
@ExampleValues({
@ExampleValues.Example(value = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", description = "Matches ISO-8601 formatted strings."),
@ExampleValues.Example(value = "dd/MMM/yyyy:HH:mm:ss Z", description = "Matches Apache Common Log Format."),
@ExampleValues.Example(value = "epoch_second", description = "Matches against strings that represent seconds since Unix epoch time.")
@Example(value = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", description = "Matches ISO-8601 formatted strings."),
@Example(value = "dd/MMM/yyyy:HH:mm:ss Z", description = "Matches Apache Common Log Format."),
@Example(value = "epoch_second", description = "Matches against strings that represent seconds since Unix epoch time.")
})
private List<String> patterns;

Expand Down Expand Up @@ -136,8 +137,8 @@ public static boolean isValidPattern(final String pattern) {
@JsonProperty(value = "output_format", defaultValue = DEFAULT_OUTPUT_FORMAT)
@JsonPropertyDescription("Determines the format of the timestamp added to an event.")
@ExampleValues({
@ExampleValues.Example(value = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", description = "Outputs ISO-8601 formatted strings."),
@ExampleValues.Example(value = "dd/MMM/yyyy:HH:mm:ss Z", description = "Outputs in Apache Common Log Format.")
@Example(value = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", description = "Outputs ISO-8601 formatted strings."),
@Example(value = "dd/MMM/yyyy:HH:mm:ss Z", description = "Outputs in Apache Common Log Format.")
})
private String outputFormat = DEFAULT_OUTPUT_FORMAT;

Expand All @@ -152,8 +153,8 @@ public static boolean isValidPattern(final String pattern) {
"A list of all the available time zones is contained in the TZ database name column of " +
"<a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List\">this table</a>.")
@ExampleValues({
@ExampleValues.Example(value = "UTC", description = "Coordinated Universal Time (UTC)."),
@ExampleValues.Example(value = "US/Pacific", description = "United States Pacific time zone.")
@Example(value = "UTC", description = "Coordinated Universal Time (UTC)."),
@Example(value = "US/Pacific", description = "United States Pacific time zone.")
})
private String sourceTimezone = DEFAULT_SOURCE_TIMEZONE;

Expand All @@ -162,8 +163,8 @@ public static boolean isValidPattern(final String pattern) {
"A list of all the available time zones is contained in the TZ database name column of " +
"<a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List\">this table</a>.")
@ExampleValues({
@ExampleValues.Example(value = "UTC", description = "Coordinated Universal Time (UTC)."),
@ExampleValues.Example(value = "US/Pacific", description = "United States Pacific time zone.")
@Example(value = "UTC", description = "Coordinated Universal Time (UTC)."),
@Example(value = "US/Pacific", description = "United States Pacific time zone.")
})
private String destinationTimezone = DEFAULT_DESTINATION_TIMEZONE;

Expand All @@ -176,8 +177,8 @@ public static boolean isValidPattern(final String pattern) {
"<a href=\"https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry\">here</a>." +
"Default is <code>Locale.ROOT</code>.")
@ExampleValues({
@ExampleValues.Example("en-US"),
@ExampleValues.Example("fr-FR")
@Example("en-US"),
@Example("fr-FR")
})
private String locale;

Expand Down

0 comments on commit d3faea7

Please sign in to comment.