Enum Class DurationValidator

java.lang.Object
java.lang.Enum<DurationValidator>
io.micrometer.core.instrument.config.validate.DurationValidator
All Implemented Interfaces:
Serializable, Comparable<DurationValidator>, Constable

@Incubating(since="1.5.0") public enum DurationValidator extends Enum<DurationValidator>
Validator for Duration.
Since:
1.5.0
  • Enum Constant Details

  • Field Details

  • Method Details

    • values

      public static DurationValidator[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DurationValidator valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • validate

      public static Validated<Duration> validate(String property, @Nullable String value)
      Detect the style then parse the value to return a duration.
      Parameters:
      property - The configuration property this duration belongs to
      value - The value to parse
      Returns:
      the parsed duration
    • doParse

      protected abstract Validated<Duration> doParse(String property, String value)
      Parse the given value to a duration.
      Parameters:
      property - The configuration property this duration belongs to
      value - The value to parse
      Returns:
      a duration
    • validateTimeUnit

      public static Validated<TimeUnit> validateTimeUnit(String property, @Nullable String unit)
    • validateChronoUnit

      public static Validated<ChronoUnit> validateChronoUnit(String property, @Nullable String value, @Nullable String unit)
      Validate a unit that is potentially part of a larger string including the magnitude of time.
      Parameters:
      property - The property that is a Duration or unit.
      value - The whole string including magnitude.
      unit - The unit portion of the string.
      Returns:
      A validated unit.