Class HolidayCalendarId

    • 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 from ReferenceData 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).

        Specified by:
        getName in interface Named
        Returns:
        the unique name
      • 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 interface Resolvable<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 interface ReferenceDataId<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.

        Overrides:
        equals in class Object
        Parameters:
        obj - the other identifier, null returns false
        Returns:
        true if equal
      • hashCode

        public int hashCode()
        Returns a suitable hash code for the identifier.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • toString

        public String toString()
        Returns the name of the identifier.
        Overrides:
        toString in class Object
        Returns:
        the name