java.lang.Object
com.pervasive.datarush.tokens.scalar.DurationToken
- All Implemented Interfaces:
DataToken,DurationValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<DurationToken>
An immutable
DurationValued object.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationTokenA null valuedDurationTokenstatic final DurationTokenA zero valuedDurationTokenstatic final DurationThe duration zero value,0. -
Constructor Summary
ConstructorsConstructorDescriptionDurationToken(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
Modifier and TypeMethodDescriptionfinal DurationGets the contained Duration value as ajava.time.Duration.longGet the contained duration value as the number of seconds.intcompareTo(DurationToken that) booleanIndicates whether another object is equal to this token.final ScalarTokenTypegetType()Gets the data type of the token.inthashCode()Returns a hash code for the token.final booleanisNull()Indicates whether the token is null valued.final booleanisZero()Indicates whether the value is the zero value for the type.static DurationTokenConverts a string representation of a Duration value into a token.intGet the subsecond portion of the contained duration value.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued
getType, isZeroMethods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
Field Details
-
NULL
A null valuedDurationToken -
ZERO_VALUE
The duration zero value,0. -
ZERO
A zero valuedDurationToken
-
-
Constructor Details
-
DurationToken
Constructs a new token with the duration value in the given container.- Parameters:
value- aDurationValuedcontaining the desired value
-
DurationToken
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 Details
-
compareTo
- Specified by:
compareToin interfaceComparable<DurationToken>
-
equals
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
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
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:
-
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:
-
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.
-
toString
-
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
-