Class BusinessDayAdjustment
- java.lang.Object
-
- com.opengamma.strata.basics.date.BusinessDayAdjustment
-
- All Implemented Interfaces:
Resolvable<DateAdjuster>,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class BusinessDayAdjustment extends Object implements Resolvable<DateAdjuster>, org.joda.beans.ImmutableBean, Serializable
An adjustment that alters a date if it falls on a day other than a business day.When processing dates in finance, it is typically intended that non-business days, such as weekends and holidays, are converted to a nearby valid business day. This class represents the necessary adjustment.
This class combines a business day convention with a holiday calendar. To adjust a date,
ReferenceDatamust be provided to resolve the holiday calendar.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBusinessDayAdjustment.BuilderThe bean-builder forBusinessDayAdjustment.static classBusinessDayAdjustment.MetaThe meta-bean forBusinessDayAdjustment.
-
Field Summary
Fields Modifier and Type Field Description static BusinessDayAdjustmentNONEAn instance that performs no adjustment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalDateadjust(LocalDate date, ReferenceData refData)Adjusts the date as necessary if it is not a business day.static BusinessDayAdjustment.Builderbuilder()Returns a builder used to create an instance of the bean.booleanequals(Object obj)HolidayCalendarIdgetCalendar()Gets the calendar that defines holidays and business days.BusinessDayConventiongetConvention()Gets the convention used to the adjust the date if it does not fall on a business day.inthashCode()static BusinessDayAdjustment.Metameta()The meta-bean forBusinessDayAdjustment.BusinessDayAdjustment.MetametaBean()static BusinessDayAdjustmentof(BusinessDayConvention convention, HolidayCalendarId calendar)Obtains an instance using the specified convention and calendar.DateAdjusterresolve(ReferenceData refData)Resolves this adjustment using the specified reference data, returning an adjuster.BusinessDayAdjustment.BuildertoBuilder()Returns a builder that allows this bean to be mutated.StringtoString()Returns a string describing the adjustment.
-
-
-
Field Detail
-
NONE
public static final BusinessDayAdjustment NONE
An instance that performs no adjustment.
-
-
Method Detail
-
of
public static BusinessDayAdjustment of(BusinessDayConvention convention, HolidayCalendarId calendar)
Obtains an instance using the specified convention and calendar.When adjusting a date, the convention rule will be applied using the specified calendar.
- Parameters:
convention- the convention used to the adjust the date if it does not fall on a business daycalendar- the calendar that defines holidays and business days- Returns:
- the adjuster
-
adjust
public LocalDate adjust(LocalDate date, ReferenceData refData)
Adjusts the date as necessary if it is not a business day.If the date is a business day it will be returned unaltered. If the date is not a business day, the convention will be applied.
- 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
DateAdjusterthat 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:
resolvein 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 BusinessDayAdjustment.Meta meta()
The meta-bean forBusinessDayAdjustment.- Returns:
- the meta-bean, not null
-
builder
public static BusinessDayAdjustment.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public BusinessDayAdjustment.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getConvention
public BusinessDayConvention getConvention()
Gets the convention used to the adjust the date if it does not fall on a business day.The convention determines whether to move forwards or backwards when it is a holiday.
- Returns:
- the value of the property, not null
-
getCalendar
public HolidayCalendarId getCalendar()
Gets the calendar that defines holidays and business days.When the adjustment is made, this calendar is used to skip holidays.
- Returns:
- the value of the property, not null
-
toBuilder
public BusinessDayAdjustment.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-