public final class PeriodToken extends Object implements ScalarToken, Comparable<PeriodToken>
PeriodValued
object.Modifier and Type | Field and Description |
---|---|
static PeriodToken |
NULL
A null valued
PeriodToken |
static PeriodToken |
ZERO
A zero valued
PeriodToken |
static Period |
ZERO_VALUE
The period zero value,
0 . |
Constructor and Description |
---|
PeriodToken(int years,
int months,
int days)
Constructs a new token with the given non-null
period value.
|
PeriodToken(Period value)
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.
|
Modifier and Type | Method and Description |
---|---|
Period |
asPeriod()
Gets the contained Period value as a
java.time.Period . |
int |
compareTo(PeriodToken that) |
boolean |
equals(Object obj)
Indicates whether another object is equal to this token.
|
int |
getDays()
Gets the day portion of the contained period value.
|
int |
getMonths()
Gets the month portion of the contained period value.
|
ScalarTokenType |
getType()
Gets the data type of the token.
|
int |
getYears()
Gets the year portion of the contained period value.
|
int |
hashCode()
Returns a hash code for the token.
|
boolean |
isNull()
Indicates whether the token is null valued.
|
boolean |
isZero()
Indicates whether the value is the zero value
for the type.
|
static PeriodToken |
parse(String value)
Converts a string representation of a Period value into
a token.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getType, isZero
isNull
public static final PeriodToken NULL
PeriodToken
public static final Period ZERO_VALUE
0
.public static final PeriodToken ZERO
PeriodToken
public PeriodToken(PeriodValued value)
value
- a PeriodValued
containing the
desired valuepublic PeriodToken(Period value)
NULL
.value
- the period value of the tokenpublic PeriodToken(int years, int months, int days)
NULL
.years
- the year portion of the periodmonths
- the month portion of the perioddays
- the day portion of the periodpublic int compareTo(PeriodToken that)
compareTo
in interface Comparable<PeriodToken>
public boolean equals(Object obj)
DataToken
TokenComparator.equal(TokenValued,TokenValued)
but makes it possible to store DataToken
s in Map
s.public int hashCode()
DataToken
TokenConverter.asHashCode(TokenValued)
.public static PeriodToken parse(String value)
value
- a string value to interpret as period;
see Period#parse(String)
public final ScalarTokenType getType()
TokenValued
getType
in interface ScalarValued
getType
in interface TokenValued
getType
in interface ScalarTyped
getType
in interface TokenTyped
public int getYears()
PeriodValued
getYears
in interface PeriodValued
TokenValued.isNull()
,
0
is returned.public int getMonths()
PeriodValued
getMonths
in interface PeriodValued
TokenValued.isNull()
,
0
is returned.public int getDays()
PeriodValued
getDays
in interface PeriodValued
TokenValued.isNull()
,
0
is returned.public final Period asPeriod()
PeriodValued
java.time.Period
.asPeriod
in interface PeriodValued
java.time.Period
. If null valued,
as indicated by TokenValued.isNull()
, null
is returned.public final boolean isZero()
ScalarValued
isZero
in interface ScalarValued
true
if the value is the zero value,
false
otherwise.public final boolean isNull()
TokenValued
isNull
in interface TokenValued
true
if the token is null valued,
false
otherwiseCopyright © 2021 Actian Corporation. All rights reserved.