Package org.apache.commons.lang3.time
Class DurationFormatUtils.Token
- java.lang.Object
-
- org.apache.commons.lang3.time.DurationFormatUtils.Token
-
- Enclosing class:
- DurationFormatUtils
static class DurationFormatUtils.Token extends java.lang.Object
Element that is parsed from the format pattern.
-
-
Field Summary
Fields Modifier and Type Field Description private int
count
private static DurationFormatUtils.Token[]
EMPTY_ARRAY
Empty array.private int
optionalIndex
private java.lang.Object
value
-
Constructor Summary
Constructors Constructor Description Token(java.lang.Object value, boolean optional, int optionalIndex)
Wraps a token around a value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static boolean
containsTokenWithValue(DurationFormatUtils.Token[] tokens, java.lang.Object value)
Helper method to determine if a set of tokens contain a valueboolean
equals(java.lang.Object obj2)
Supports equality of this Token to another Token.(package private) int
getCount()
Gets the current number of values represented(package private) java.lang.Object
getValue()
Gets the particular value this token represents.int
hashCode()
Returns a hash code for the token equal to the hash code for the token's value.(package private) void
increment()
Adds another one of the valuejava.lang.String
toString()
Represents this token as a String.
-
-
-
Field Detail
-
EMPTY_ARRAY
private static final DurationFormatUtils.Token[] EMPTY_ARRAY
Empty array.
-
value
private final java.lang.Object value
-
count
private int count
-
optionalIndex
private int optionalIndex
-
-
Constructor Detail
-
Token
Token(java.lang.Object value, boolean optional, int optionalIndex)
Wraps a token around a value. A value would be something like a 'Y'.- Parameters:
value
- value to wrap, non-null.optional
- whether the token is optionaloptionalIndex
- the index of the optional token within the pattern
-
-
Method Detail
-
containsTokenWithValue
static boolean containsTokenWithValue(DurationFormatUtils.Token[] tokens, java.lang.Object value)
Helper method to determine if a set of tokens contain a value- Parameters:
tokens
- set to look invalue
- to look for- Returns:
- boolean
true
if contained
-
equals
public boolean equals(java.lang.Object obj2)
Supports equality of this Token to another Token.- Overrides:
equals
in classjava.lang.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
java.lang.Object getValue()
Gets the particular value this token represents.- Returns:
- Object value, non-null.
-
hashCode
public int hashCode()
Returns a hash code for the token equal to the hash code for the token's value. Thus 'TT' and 'TTTT' will have the same hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code for the token
-
increment
void increment()
Adds another one of the value
-
toString
public java.lang.String toString()
Represents this token as a String.- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representation of the token
-
-