public interface DateSequence extends Named
This interface encapsulates a sequence of dates as used in standard financial instruments. The most common are the quarterly IMM dates, which are on the third Wednesday of March, June, September and December.
The most common implementations are provided in DateSequences
.
Note that the dates produced by the sequence may not be business days. The application of a holiday calendar is typically the responsibility of the caller.
All implementations of this interface must be immutable and threadsafe.
Modifier and Type  Method and Description 

LocalDate 
dateMatching(YearMonth yearMonth)
Finds the date in the sequence that corresponds to the specified yearmonth.

static ExtendedEnum<DateSequence> 
extendedEnum()
Gets the extended enum helper.

String 
getName()
Gets the name that uniquely identifies this sequence.

default LocalDate 
next(LocalDate date)
Finds the next date in the sequence, always returning a date later than the input date.

LocalDate 
nextOrSame(LocalDate date)
Finds the next date in the sequence, returning the input date if it is a date in the sequence.

default LocalDate 
nth(LocalDate date,
int sequenceNumber)
Finds the nth date in the sequence after the input date,
always returning a date later than the input date.

default LocalDate 
nthOrSame(LocalDate date,
int sequenceNumber)
Finds the nth date in the sequence on or after the input date,
returning the input date if it is a date in the sequence.

static DateSequence 
of(String uniqueName)
Obtains an instance from the specified unique name.

static DateSequence of(String uniqueName)
uniqueName
 the unique nameIllegalArgumentException
 if the name is not knownstatic ExtendedEnum<DateSequence> extendedEnum()
This helper allows instances of the sequence to be looked up. It also provides the complete set of available instances.
default LocalDate next(LocalDate date)
Given an input date, this method returns the next date after it from the sequence.
date
 the input dateIllegalArgumentException
 if there are no more sequence datesLocalDate nextOrSame(LocalDate date)
Given an input date, this method returns a date from the sequence. If the input date is in the sequence, it is returned. Otherwise, the next date in the sequence after the input date is returned.
date
 the input dateIllegalArgumentException
 if there are no more sequence datesdefault LocalDate nth(LocalDate date, int sequenceNumber)
Given an input date, this method returns a date from the sequence. If the sequence number is 1, then the first date in the sequence after the input date is returned.
If the sequence number is 2 or larger, then the date referred to by sequence number 1 is calculated, and the nth matching sequence date after that date returned.
date
 the input datesequenceNumber
 the 1based index of the date to findIllegalArgumentException
 if the sequence number is zero or negative or if there are no more sequence datesdefault LocalDate nthOrSame(LocalDate date, int sequenceNumber)
Given an input date, this method returns a date from the sequence. If the sequence number is 1, then either the input date or the first date in the sequence after the input date is returned.
If the sequence number is 2 or larger, then the date referred to by sequence number 1 is calculated, and the nth matching sequence date after that date returned.
date
 the input datesequenceNumber
 the 1based index of the date to findIllegalArgumentException
 if the sequence number is zero or negative or if there are no more sequence datesLocalDate dateMatching(YearMonth yearMonth)
Given an input month, this method returns the date from the sequence that is associated with the yearmonth. In most cases, the returned date will be in the same month as the input month, but this is not guaranteed.
yearMonth
 the input yearmonthIllegalArgumentException
 if there are no more sequence datesString getName()
This name is used in serialization and can be parsed using of(String)
.
Copyright 2009Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.