Class TenorAdjustment
- java.lang.Object
-
- com.opengamma.strata.basics.date.TenorAdjustment
-
- All Implemented Interfaces:
Resolvable<DateAdjuster>
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class TenorAdjustment extends Object implements Resolvable<DateAdjuster>, org.joda.beans.ImmutableBean, Serializable
An adjustment that alters a date by adding a tenor.This adjustment adds a
Tenor
to the input date using an addition convention, followed by an adjustment to ensure the result is a valid business day.Addition is performed using standard calendar addition. It is not possible to add a number of business days using this class. See
DaysAdjustment
for an alternative that can handle addition of business days.There are two steps in the calculation:
In step one, the period is added using the specified
PeriodAdditionConvention
.In step two, the result of step one is optionally adjusted to be a business day using a
BusinessDayAdjustment
.For example, a rule represented by this class might be: "the end date is 5 years after the start date, with end-of-month rule based on the last business day of the month, adjusted to be a valid London business day using the 'ModifiedFollowing' convention".
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TenorAdjustment.Builder
The bean-builder forTenorAdjustment
.static class
TenorAdjustment.Meta
The meta-bean forTenorAdjustment
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalDate
adjust(LocalDate date, ReferenceData refData)
Adjusts the date, adding the tenor and then applying the business day adjustment.static TenorAdjustment.Builder
builder()
Returns a builder used to create an instance of the bean.boolean
equals(Object obj)
PeriodAdditionConvention
getAdditionConvention()
Gets the addition convention to apply.BusinessDayAdjustment
getAdjustment()
Gets the business day adjustment that is performed to the result of the addition.Tenor
getTenor()
Gets the tenor to be added.int
hashCode()
static TenorAdjustment.Meta
meta()
The meta-bean forTenorAdjustment
.TenorAdjustment.Meta
metaBean()
static TenorAdjustment
of(Tenor tenor, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
Obtains an instance that can adjust a date by the specified tenor.static TenorAdjustment
ofLastBusinessDay(Tenor tenor, BusinessDayAdjustment adjustment)
Obtains an instance that can adjust a date by the specified tenor using the last business day of month convention.static TenorAdjustment
ofLastDay(Tenor tenor, BusinessDayAdjustment adjustment)
Obtains an instance that can adjust a date by the specified tenor using the last day of month convention.DateAdjuster
resolve(ReferenceData refData)
Resolves this adjustment using the specified reference data, returning an adjuster.TenorAdjustment.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
Returns a string describing the adjustment.
-
-
-
Method Detail
-
of
public static TenorAdjustment of(Tenor tenor, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
Obtains an instance that can adjust a date by the specified tenor.When adjusting a date, the specified tenor is added to the input date. The business day adjustment will then be used to ensure the result is a valid business day.
- Parameters:
tenor
- the tenor to add to the input dateadditionConvention
- the convention used to perform the additionadjustment
- the business day adjustment to apply to the result of the addition- Returns:
- the tenor adjustment
-
ofLastDay
public static TenorAdjustment ofLastDay(Tenor tenor, BusinessDayAdjustment adjustment)
Obtains an instance that can adjust a date by the specified tenor using the last day of month convention.When adjusting a date, the specified tenor is added to the input date. The business day adjustment will then be used to ensure the result is a valid business day.
The period must consist only of months and/or years.
- Parameters:
tenor
- the tenor to add to the input dateadjustment
- the business day adjustment to apply to the result of the addition- Returns:
- the tenor adjustment
-
ofLastBusinessDay
public static TenorAdjustment ofLastBusinessDay(Tenor tenor, BusinessDayAdjustment adjustment)
Obtains an instance that can adjust a date by the specified tenor using the last business day of month convention.When adjusting a date, the specified tenor is added to the input date. The business day adjustment will then be used to ensure the result is a valid business day.
The period must consist only of months and/or years.
- Parameters:
tenor
- the tenor to add to the input dateadjustment
- the business day adjustment to apply to the result of the addition- Returns:
- the tenor adjustment
-
adjust
public LocalDate adjust(LocalDate date, ReferenceData refData)
Adjusts the date, adding the tenor and then applying the business day adjustment.The calculation is performed in two steps.
Step one, use
PeriodAdditionConvention.adjust(LocalDate, Period, HolidayCalendar)
to add the period.Step two, use
BusinessDayAdjustment.adjust(LocalDate, ReferenceData)
to adjust the result of step one.- Parameters:
date
- the date to adjustrefData
- the reference data, used to find the holiday calendar- Returns:
- the adjusted date
-
resolve
public DateAdjuster resolve(ReferenceData refData)
Resolves this adjustment using the specified reference data, returning an adjuster.This returns a
DateAdjuster
that performs the same calculation as this adjustment. It binds the holiday calendar, looked up from the reference data, into the result. As such, there is no need to pass the reference data in again.- Specified by:
resolve
in interfaceResolvable<DateAdjuster>
- Parameters:
refData
- the reference data, used to find the holiday calendar- Returns:
- the adjuster, bound to a specific holiday calendar
-
toString
public String toString()
Returns a string describing the adjustment.
-
meta
public static TenorAdjustment.Meta meta()
The meta-bean forTenorAdjustment
.- Returns:
- the meta-bean, not null
-
builder
public static TenorAdjustment.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public TenorAdjustment.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getTenor
public Tenor getTenor()
Gets the tenor to be added.When the adjustment is performed, this tenor will be added to the input date.
- Returns:
- the value of the property, not null
-
getAdditionConvention
public PeriodAdditionConvention getAdditionConvention()
Gets the addition convention to apply.When the adjustment is performed, this convention is used to refine the adjusted date. The most common convention is to move the end date to the last business day of the month if the start date is the last business day of the month.
- Returns:
- the value of the property, not null
-
getAdjustment
public BusinessDayAdjustment getAdjustment()
Gets the business day adjustment that is performed to the result of the addition.This adjustment is applied to the result of the addition calculation.
If no adjustment is required, use the 'None' business day adjustment.
- Returns:
- the value of the property, not null
-
toBuilder
public TenorAdjustment.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-