Class HolidayCalendarId
- java.lang.Object
-
- com.opengamma.strata.basics.date.HolidayCalendarId
-
- All Implemented Interfaces:
ReferenceDataId<HolidayCalendar>
,Resolvable<HolidayCalendar>
,Named
,Serializable
public final class HolidayCalendarId extends Object implements ReferenceDataId<HolidayCalendar>, Resolvable<HolidayCalendar>, Named, Serializable
An identifier for a holiday calendar.This identifier is used to obtain a
HolidayCalendar
fromReferenceData
. The holiday calendar itself is used to determine whether a day is a business day or not.Identifiers for common holiday calendars are provided in
HolidayCalendarIds
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HolidayCalendarId
combinedWith(HolidayCalendarId other)
Combines this holiday calendar identifier with another.static HolidayCalendarId
defaultByCurrency(Currency currency)
Gets the default calendar for a currency.static HolidayCalendarId
defaultByCurrencyPair(CurrencyPair currencyPair)
Gets the default calendar for a pair of currencies.boolean
equals(Object obj)
Checks if this identifier equals another identifier.static Optional<HolidayCalendarId>
findDefaultByCurrency(Currency currency)
Tries to find a default calendar for a currency.String
getName()
Gets the name that uniquely identifies this calendar.Class<HolidayCalendar>
getReferenceDataType()
Gets the type of data this identifier refers to.int
hashCode()
Returns a suitable hash code for the identifier.static boolean
isCompositeCalendar(HolidayCalendarId id)
Checks if the holiday calendar is a combined or linked calendar.HolidayCalendarId
linkedWith(HolidayCalendarId other)
Combines this holiday calendar identifier with another.static HolidayCalendarId
of(String uniqueName)
Obtains an instance from the specified unique name.HolidayCalendar
queryValueOrNull(ReferenceData refData)
Low-level method to query the reference data value associated with this identifier, returning null if not found.HolidayCalendar
resolve(ReferenceData refData)
Resolves this identifier to a holiday calendar using the specified reference data.String
toString()
Returns the name of the identifier.
-
-
-
Method Detail
-
of
public static HolidayCalendarId of(String uniqueName)
Obtains an instance from the specified unique name.The name uniquely identifies the calendar. The
HolidayCalendar
is resolved fromReferenceData
when required.It is possible to combine two or more calendars using the '+' symbol. For example, 'GBLO+USNY' will combine the separate 'GBLO' and 'USNY' calendars. The resulting identifier will have the individual identifiers normalized into alphabetical order.
- Parameters:
uniqueName
- the unique name- Returns:
- the identifier
-
defaultByCurrency
public static HolidayCalendarId defaultByCurrency(Currency currency)
Gets the default calendar for a currency.This uses data from
HolidayCalendarDefaultData.ini
to provide a default.- Parameters:
currency
- the currency to find the default for- Returns:
- the holiday calendar
- Throws:
IllegalArgumentException
- if there is no default for the currency
-
findDefaultByCurrency
public static Optional<HolidayCalendarId> findDefaultByCurrency(Currency currency)
Tries to find a default calendar for a currency.This uses data from
HolidayCalendarDefaultData.ini
to provide a default.- Parameters:
currency
- the currency to find the default for- Returns:
- the holiday calendar, empty if no calendar found
-
defaultByCurrencyPair
public static HolidayCalendarId defaultByCurrencyPair(CurrencyPair currencyPair)
Gets the default calendar for a pair of currencies.This uses data from
HolidayCalendarDefaultData.ini
to provide a default.If no calendar is found, the 'NoHolidays' calendar is used as the default.
- Parameters:
currencyPair
- the currency pair to find the defaults for- Returns:
- the holiday calendar
-
isCompositeCalendar
public static boolean isCompositeCalendar(HolidayCalendarId id)
Checks if the holiday calendar is a combined or linked calendar.- Parameters:
id
- the holiday calendar id- Returns:
- if the holiday calendar is a combined or linked calendar
-
getName
public String getName()
Gets the name that uniquely identifies this calendar.This name is used in serialization and can be parsed using
of(String)
.
-
getReferenceDataType
public Class<HolidayCalendar> getReferenceDataType()
Gets the type of data this identifier refers to.A
HolidayCalendarId
refers to aHolidayCalendar
.- Specified by:
getReferenceDataType
in interfaceReferenceDataId<HolidayCalendar>
- Returns:
- the type of the reference data this identifier refers to
-
resolve
public HolidayCalendar resolve(ReferenceData refData)
Resolves this identifier to a holiday calendar using the specified reference data.This returns an instance of
HolidayCalendar
that can perform calculations.Resolved objects may be bound to data that changes over time, such as holiday calendars. If the data changes, such as the addition of a new holiday, the resolved form will not be updated. Care must be taken when placing the resolved form in a cache or persistence layer.
- Specified by:
resolve
in interfaceResolvable<HolidayCalendar>
- Parameters:
refData
- the reference data, used to resolve the reference- Returns:
- the resolved holiday calendar
- Throws:
ReferenceDataNotFoundException
- if the identifier is not found
-
queryValueOrNull
public HolidayCalendar queryValueOrNull(ReferenceData refData)
Description copied from interface:ReferenceDataId
Low-level method to query the reference data value associated with this identifier, returning null if not found.This is a low-level method that obtains the reference data value, returning null instead of an error. Applications should use
ReferenceData.getValue(ReferenceDataId)
in preference to this method.- Specified by:
queryValueOrNull
in interfaceReferenceDataId<HolidayCalendar>
- Parameters:
refData
- the reference data to lookup the value in- Returns:
- the reference data value, null if not found
-
combinedWith
public HolidayCalendarId combinedWith(HolidayCalendarId other)
Combines this holiday calendar identifier with another.The resulting calendar will declare a day as a business day if it is a business day in both source calendars.
- Parameters:
other
- the other holiday calendar identifier- Returns:
- the combined holiday calendar identifier
-
linkedWith
public HolidayCalendarId linkedWith(HolidayCalendarId other)
Combines this holiday calendar identifier with another.The resulting calendar will declare a day as a business day if it is a business day in either source calendar.
- Parameters:
other
- the other holiday calendar identifier- Returns:
- the combined holiday calendar identifier
-
equals
public boolean equals(Object obj)
Checks if this identifier equals another identifier.The comparison checks the name.
-
hashCode
public int hashCode()
Returns a suitable hash code for the identifier.
-
-