- java.lang.Object
-
- com.pervasive.datarush.tokens.scalar.DurationToken
-
- All Implemented Interfaces:
DataToken,DurationValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<DurationToken>
public final class DurationToken extends Object implements ScalarToken, Comparable<DurationToken>
An immutableDurationValuedobject.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static DurationTokenNULLA null valuedDurationTokenstatic DurationTokenZEROA zero valuedDurationTokenstatic DurationZERO_VALUEThe duration zero value,0.
-
Constructor Summary
Constructors Constructor Description DurationToken(long seconds, int nanos)Constructs a new token with the given non-null duration value.DurationToken(DurationValued value)Constructs a new token with the duration value in the given container.DurationToken(Duration value)Constructs a new token with the given non-null duration value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DurationasDuration()Gets the contained Duration value as ajava.time.Duration.longasSeconds()Get the contained duration value as the number of seconds.intcompareTo(DurationToken that)booleanequals(Object obj)Indicates whether another object is equal to this token.ScalarTokenTypegetType()Gets the data type of the token.inthashCode()Returns a hash code for the token.booleanisNull()Indicates whether the token is null valued.booleanisZero()Indicates whether the value is the zero value for the type.static DurationTokenparse(String value)Converts a string representation of a Duration value into a token.intsubsecNanos()Get the subsecond portion of the contained duration value.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued
getType, isZero
-
Methods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
-
-
-
Field Detail
-
NULL
public static final DurationToken NULL
A null valuedDurationToken
-
ZERO_VALUE
public static final Duration ZERO_VALUE
The duration zero value,0.
-
ZERO
public static final DurationToken ZERO
A zero valuedDurationToken
-
-
Constructor Detail
-
DurationToken
public DurationToken(DurationValued value)
Constructs a new token with the duration value in the given container.- Parameters:
value- aDurationValuedcontaining the desired value
-
DurationToken
public DurationToken(Duration value)
Constructs a new token with the given non-null duration value. If a null valued token is desired, useNULL.- Parameters:
value- the duration value of the token
-
DurationToken
public DurationToken(long seconds, int nanos)Constructs a new token with the given non-null duration value. If a null valued token is desired, useNULL.- Parameters:
seconds- the second portion of the durationnanos- the subsecond portion of the duration
-
-
Method Detail
-
compareTo
public int compareTo(DurationToken that)
- Specified by:
compareToin interfaceComparable<DurationToken>
-
equals
public boolean equals(Object obj)
Description copied from interface:DataTokenIndicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior ofTokenComparator.equal(TokenValued,TokenValued)but makes it possible to storeDataTokens inMaps.
-
hashCode
public int hashCode()
Description copied from interface:DataTokenReturns a hash code for the token. This value is guaranteed to be consistent with that returned byTokenConverter.asHashCode(TokenValued).
-
parse
public static DurationToken parse(String value)
Converts a string representation of a Duration value into a token.- Parameters:
value- a string value to interpret as duration; seeDuration#parse(String)- Returns:
- a token with the specified value
-
getType
public final ScalarTokenType getType()
Description copied from interface:TokenValuedGets the data type of the token. This type will dictate the valid values that can be contained.- Specified by:
getTypein interfaceScalarTyped- Specified by:
getTypein interfaceScalarValued- Specified by:
getTypein interfaceTokenTyped- Specified by:
getTypein interfaceTokenValued- Returns:
- the token type.
-
asSeconds
public long asSeconds()
Description copied from interface:DurationValuedGet the contained duration value as the number of seconds.- Specified by:
asSecondsin interfaceDurationValued- Returns:
- the contained value as seconds.
If null valued, as indicated by
TokenValued.isNull(),0is returned. - See Also:
DurationValued.subsecNanos()
-
subsecNanos
public int subsecNanos()
Description copied from interface:DurationValuedGet the subsecond portion of the contained duration value.- Specified by:
subsecNanosin interfaceDurationValued- Returns:
- the subsecond portion of the contained value, in
nanoseconds. If null valued, as indicated by
TokenValued.isNull(),0is returned. - See Also:
DurationValued.asSeconds()
-
asDuration
public final Duration asDuration()
Description copied from interface:DurationValuedGets the contained Duration value as ajava.time.Duration.- Specified by:
asDurationin interfaceDurationValued- Returns:
- the contained value as a
java.time.Duration. If null valued, as indicated byTokenValued.isNull(),nullis returned.
-
isZero
public final boolean isZero()
Description copied from interface:ScalarValuedIndicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.- Specified by:
isZeroin interfaceScalarValued- Returns:
trueif the value is the zero value,falseotherwise.
-
isNull
public final boolean isNull()
Description copied from interface:TokenValuedIndicates whether the token is null valued. Tokens support null values analogous to SQL. Before accessing the value of the container, it is usually best to ensure it is not null valued using this method.- Specified by:
isNullin interfaceTokenValued- Returns:
trueif the token is null valued,falseotherwise
-
-