@Incubating(since="1.5.0") public enum DurationValidator extends java.lang.Enum<DurationValidator>
Duration
.Enum Constant and Description |
---|
ISO8601 |
SIMPLE
Human readable formatting, for example '1s'.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.util.regex.Pattern> |
patterns |
Modifier and Type | Method and Description |
---|---|
protected abstract Validated<java.time.Duration> |
doParse(java.lang.String property,
java.lang.String value)
Parse the given value to a duration.
|
static Validated<java.time.Duration> |
validate(java.lang.String property,
java.lang.String value)
Detect the style then parse the value to return a duration.
|
static Validated<java.time.temporal.ChronoUnit> |
validateChronoUnit(java.lang.String property,
java.lang.String value,
java.lang.String unit)
Validate a unit that is potentially part of a larger string including the magnitude of time.
|
static Validated<java.util.concurrent.TimeUnit> |
validateTimeUnit(java.lang.String property,
java.lang.String unit) |
static DurationValidator |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static DurationValidator[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DurationValidator SIMPLE
public static final DurationValidator ISO8601
public static DurationValidator[] values()
for (DurationValidator c : DurationValidator.values()) System.out.println(c);
public static DurationValidator valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static Validated<java.time.Duration> validate(java.lang.String property, @Nullable java.lang.String value)
property
- The configuration property this duration belongs tovalue
- The value to parseprotected abstract Validated<java.time.Duration> doParse(java.lang.String property, java.lang.String value)
property
- The configuration property this duration belongs tovalue
- The value to parsepublic static Validated<java.util.concurrent.TimeUnit> validateTimeUnit(java.lang.String property, @Nullable java.lang.String unit)
public static Validated<java.time.temporal.ChronoUnit> validateChronoUnit(java.lang.String property, @Nullable java.lang.String value, @Nullable java.lang.String unit)
property
- The property that is a Duration
or unit.value
- The whole string including magnitude.unit
- The unit portion of the string.