java.lang.Object
com.pervasive.datarush.tokens.scalar.PeriodToken
- All Implemented Interfaces:
DataToken,PeriodValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<PeriodToken>
An immutable
PeriodValued object.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PeriodTokenA null valuedPeriodTokenstatic final PeriodTokenA zero valuedPeriodTokenstatic final PeriodThe period zero value,0. -
Constructor Summary
ConstructorsConstructorDescriptionPeriodToken(int years, int months, int days) Constructs a new token with the given non-null period value.PeriodToken(PeriodValued value) Constructs a new token with the period value in the given container.PeriodToken(Period value) Constructs a new token with the given non-null period value. -
Method Summary
Modifier and TypeMethodDescriptionfinal PeriodasPeriod()Gets the contained Period value as ajava.time.Period.intcompareTo(PeriodToken that) booleanIndicates whether another object is equal to this token.intgetDays()Gets the day portion of the contained period value.intGets the month portion of the contained period value.final ScalarTokenTypegetType()Gets the data type of the token.intgetYears()Gets the year portion of the contained period value.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 PeriodTokenConverts a string representation of a Period value into a token.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 valuedPeriodToken -
ZERO_VALUE
The period zero value,0. -
ZERO
A zero valuedPeriodToken
-
-
Constructor Details
-
PeriodToken
Constructs a new token with the period value in the given container.- Parameters:
value- aPeriodValuedcontaining the desired value
-
PeriodToken
Constructs a new token with the given non-null period value. If a null valued token is desired, useNULL.- Parameters:
value- the period value of the token
-
PeriodToken
public PeriodToken(int years, int months, int days) Constructs a new token with the given non-null period value. If a null valued token is desired, useNULL.- Parameters:
years- the year portion of the periodmonths- the month portion of the perioddays- the day portion of the period
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<PeriodToken>
-
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 Period value into a token.- Parameters:
value- a string value to interpret as period; seePeriod.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.
-
getYears
public int getYears()Description copied from interface:PeriodValuedGets the year portion of the contained period value.- Specified by:
getYearsin interfacePeriodValued- Returns:
- the year portion of the contained value
If null valued, as indicated by
TokenValued.isNull(),0is returned.
-
getMonths
public int getMonths()Description copied from interface:PeriodValuedGets the month portion of the contained period value. This does not include the year portion.- Specified by:
getMonthsin interfacePeriodValued- Returns:
- the month portion of the contained value
If null valued, as indicated by
TokenValued.isNull(),0is returned.
-
getDays
public int getDays()Description copied from interface:PeriodValuedGets the day portion of the contained period value. This does not include the year or month portion.- Specified by:
getDaysin interfacePeriodValued- Returns:
- the day portion of the contained value
If null valued, as indicated by
TokenValued.isNull(),0is returned.
-
asPeriod
Description copied from interface:PeriodValuedGets the contained Period value as ajava.time.Period.- Specified by:
asPeriodin interfacePeriodValued- Returns:
- the contained value as a
java.time.Period. 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
-