Class SequenceDate
- java.lang.Object
-
- com.opengamma.strata.basics.date.SequenceDate
-
- All Implemented Interfaces:
Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class SequenceDate extends Object implements org.joda.beans.ImmutableBean, Serializable
Instructions to obtain a specific date from a sequence of dates.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.
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 forSequenceDate
.org.joda.beans.TypedMetaBean<SequenceDate>
metaBean()
String
toString()
-
-
-
Method Detail
-
base
public static SequenceDate base(YearMonth yearMonth)
Obtains an instance that selects the next base sequence date on or after the start of the specified month.- Parameters:
yearMonth
- the month to start from- Returns:
- the sequence date
-
base
public 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.- Parameters:
yearMonth
- the month to start fromsequenceNumber
- the 1-based sequence number of the futures, not zero or negative- Returns:
- the sequence date
-
base
public static SequenceDate base(int sequenceNumber)
Obtains an instance that selects the nth base sequence date on or after the input date.- Parameters:
sequenceNumber
- the 1-based sequence number of the futures- Returns:
- the sequence date
-
base
public 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.- Parameters:
minimumPeriod
- minimum period between the input date and the first sequence datesequenceNumber
- the 1-based sequence number of the futures, not zero or negative- Returns:
- the sequence date
-
full
public static SequenceDate full(YearMonth yearMonth)
Obtains an instance that selects the next full sequence date on or after the start of the specified month.- Parameters:
yearMonth
- the month to start from- Returns:
- the sequence date
-
full
public 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.- Parameters:
yearMonth
- the month to start fromsequenceNumber
- the 1-based sequence number of the futures, not zero or negative- Returns:
- the sequence date
-
full
public static SequenceDate full(int sequenceNumber)
Obtains an instance that selects the nth full sequence date on or after the input date.- Parameters:
sequenceNumber
- the 1-based sequence number of the futures- Returns:
- the sequence date
-
full
public 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.- Parameters:
minimumPeriod
- minimum period between the input date and the first sequence datesequenceNumber
- the 1-based sequence number of the futures, not zero or negative- Returns:
- the sequence date
-
meta
public static org.joda.beans.TypedMetaBean<SequenceDate> meta()
The meta-bean forSequenceDate
.- Returns:
- the meta-bean, not null
-
metaBean
public org.joda.beans.TypedMetaBean<SequenceDate> metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getYearMonth
public Optional<YearMonth> getYearMonth()
Gets the base year-month.The start of this month is used instead of the input date when starting to count the sequence.
- Returns:
- the optional value of the property, not null
-
getMinimumPeriod
public Optional<Period> getMinimumPeriod()
Gets the minimum period before using the sequence number.This is added to the input date before starting to count the sequence.
- Returns:
- the optional value of the property, not null
-
getSequenceNumber
public int getSequenceNumber()
Gets the 1-based sequence number.A value of 1 obtains the first date in the sequence.
- Returns:
- the value of the property
-
isFullSequence
public boolean isFullSequence()
Gets whether to use the full sequence (true) or base sequence (false).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".
- Returns:
- the value of the property
-
-