Enum DurationValidator
java.lang.Object
java.lang.Enum<DurationValidator>
io.micrometer.core.instrument.config.validate.DurationValidator
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<DurationValidator>
,java.lang.constant.Constable
@Incubating(since="1.5.0") public enum DurationValidator extends java.lang.Enum<DurationValidator>
Validator for
Duration
.- Since:
- 1.5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>>
-
Enum Constant Summary
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.util.regex.Pattern>
patterns
-
Method Summary
Modifier and Type Method 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.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Enum Constant Details
-
SIMPLE
Human readable formatting, for example '1s'. -
ISO8601
-
-
Field Details
-
patterns
protected final java.util.List<java.util.regex.Pattern> patterns
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
validate
public static Validated<java.time.Duration> validate(java.lang.String property, @Nullable java.lang.String value)Detect the style then parse the value to return a duration.- Parameters:
property
- The configuration property this duration belongs tovalue
- The value to parse- Returns:
- the parsed duration
-
doParse
protected abstract Validated<java.time.Duration> doParse(java.lang.String property, java.lang.String value)Parse the given value to a duration.- Parameters:
property
- The configuration property this duration belongs tovalue
- The value to parse- Returns:
- a duration
-
validateTimeUnit
-
validateChronoUnit
public static Validated<java.time.temporal.ChronoUnit> validateChronoUnit(java.lang.String property, @Nullable java.lang.String value, @Nullable java.lang.String unit)Validate a unit that is potentially part of a larger string including the magnitude of time.- Parameters:
property
- The property that is aDuration
or unit.value
- The whole string including magnitude.unit
- The unit portion of the string.- Returns:
- A validated unit.
-