public final class SequenceDate extends Object implements org.joda.beans.ImmutableBean, Serializable
A DateSequence
can be complex, with interlinked sub-sequences.
This class allows the instructions for specifying a single date from the sequence to be expressed.
For example, the "base sequence" of a future is often March, June, September and December. But additionally, the nearest two "serial" months are also listed. Together these make the "full sequence".
This class can be setup to select from either the base or full sequence, and starting from a specific year-month or from the input date plus a period.
Modifier and Type | Method and Description |
---|---|
static SequenceDate |
base(int sequenceNumber)
Obtains an instance that selects the nth base sequence date on or after the input date.
|
static SequenceDate |
base(Period minimumPeriod,
int sequenceNumber)
Obtains an instance that selects the nth base sequence date on or after the input date
once the minimum period is added.
|
static SequenceDate |
base(YearMonth yearMonth)
Obtains an instance that selects the next base sequence date on or after the start of the specified month.
|
static SequenceDate |
base(YearMonth yearMonth,
int sequenceNumber)
Obtains an instance that selects the nth base sequence date on or after the start of the specified month.
|
boolean |
equals(Object obj) |
static SequenceDate |
full(int sequenceNumber)
Obtains an instance that selects the nth full sequence date on or after the input date.
|
static SequenceDate |
full(Period minimumPeriod,
int sequenceNumber)
Obtains an instance that selects the nth full sequence date on or after the input date
once the minimum period is added.
|
static SequenceDate |
full(YearMonth yearMonth)
Obtains an instance that selects the next full sequence date on or after the start of the specified month.
|
static SequenceDate |
full(YearMonth yearMonth,
int sequenceNumber)
Obtains an instance that selects the nth full sequence date on or after the start of the specified month.
|
Optional<Period> |
getMinimumPeriod()
Gets the minimum period before using the sequence number.
|
int |
getSequenceNumber()
Gets the 1-based sequence number.
|
Optional<YearMonth> |
getYearMonth()
Gets the base year-month.
|
int |
hashCode() |
boolean |
isFullSequence()
Gets whether to use the full sequence (true) or base sequence (false).
|
static org.joda.beans.TypedMetaBean<SequenceDate> |
meta()
The meta-bean for
SequenceDate . |
org.joda.beans.TypedMetaBean<SequenceDate> |
metaBean() |
String |
toString() |
public static SequenceDate base(YearMonth yearMonth)
yearMonth
- the month to start frompublic static SequenceDate base(YearMonth yearMonth, int sequenceNumber)
yearMonth
- the month to start fromsequenceNumber
- the 1-based sequence number of the futures, not zero or negativepublic static SequenceDate base(int sequenceNumber)
sequenceNumber
- the 1-based sequence number of the futurespublic static SequenceDate base(Period minimumPeriod, int sequenceNumber)
minimumPeriod
- minimum period between the input date and the first sequence datesequenceNumber
- the 1-based sequence number of the futures, not zero or negativepublic static SequenceDate full(YearMonth yearMonth)
yearMonth
- the month to start frompublic static SequenceDate full(YearMonth yearMonth, int sequenceNumber)
yearMonth
- the month to start fromsequenceNumber
- the 1-based sequence number of the futures, not zero or negativepublic static SequenceDate full(int sequenceNumber)
sequenceNumber
- the 1-based sequence number of the futurespublic static SequenceDate full(Period minimumPeriod, int sequenceNumber)
minimumPeriod
- minimum period between the input date and the first sequence datesequenceNumber
- the 1-based sequence number of the futures, not zero or negativepublic static org.joda.beans.TypedMetaBean<SequenceDate> meta()
SequenceDate
.public org.joda.beans.TypedMetaBean<SequenceDate> metaBean()
metaBean
in interface org.joda.beans.Bean
public Optional<YearMonth> getYearMonth()
The start of this month is used instead of the input date when starting to count the sequence.
public Optional<Period> getMinimumPeriod()
This is added to the input date before starting to count the sequence.
public int getSequenceNumber()
A value of 1 obtains the first date in the sequence.
public boolean isFullSequence()
Many date sequences have two interlinked sequences. One is considered to be the base sequence, selected by setting this to false. The other is considered to be the full sequence, selected by setting this to true.
For example, the "base sequence" of a future is often March, June, September and December. But additionally, the nearest two "serial" months are also listed. Together these make the "full sequence".
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.