Class DurationFormatUtils.Token

java.lang.Object
org.apache.commons.lang3.time.DurationFormatUtils.Token
Enclosing class:
DurationFormatUtils

static final class DurationFormatUtils.Token extends Object
Element that is parsed from the format pattern.
  • Field Details

  • Constructor Details

    • Token

      Token(StringBuilder literal, boolean optional, int optionalIndex)
      Wraps a token around literal text.
      Parameters:
      literal - literal text to wrap, non-null.
      optional - whether the token is optional.
      optionalIndex - The index of the optional token within the pattern.
    • Token

      Token(DurationFormatUtils.Unit value, boolean optional, int optionalIndex)
      Wraps a token around a duration unit.
      Parameters:
      value - duration unit to wrap, non-null.
      optional - whether the token is optional.
      optionalIndex - The index of the optional token within the pattern.
  • Method Details

    • containsTokenWithValue

      static boolean containsTokenWithValue(DurationFormatUtils.Token[] tokens, DurationFormatUtils.Unit value)
      Determines whether a set of tokens contains a duration unit.
      Parameters:
      tokens - set to search.
      value - duration unit to find.
      Returns:
      boolean true if contained.
    • equals

      public boolean equals(Object obj2)
      Supports equality of this Token to another Token.
      Overrides:
      equals in class Object
      Parameters:
      obj2 - Object to consider equality of.
      Returns:
      boolean true if equal.
    • getCount

      int getCount()
      Gets the current number of values represented.
      Returns:
      int number of values represented.
    • getValue

      Gets the duration unit this token represents.
      Returns:
      the duration unit, or null for a literal token.
    • hashCode

      public int hashCode()
      Computes a hash code from the duration unit or literal text, excluding the repetition count.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code for the token.
    • increment

      void increment()
      Adds another one of the value.
    • toString

      public String toString()
      Represents this token as a String.
      Overrides:
      toString in class Object
      Returns:
      String representation of the token.