All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.objectlab.kit.datecalc.common.ccy.DefaultCurrencyCalculatorConfig Maven / Gradle / Ivy

There is a newer version: 1.4.8
Show newest version
package net.objectlab.kit.datecalc.common.ccy;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import net.objectlab.kit.datecalc.common.CurrencyDateCalculator;
import net.objectlab.kit.datecalc.common.WorkingWeek;

/**
 * Default for:
 * 
  • currencies subject to USD Holidays for T+1: MXN, CLP, ARS (Mexican Peso, Chile Pese and Argentina Peso).
  • *
  • Arabic currencies Sun-Thu: AED, BHD, EGP, KWD, OMR, QAR.
  • *
  • Arabic currencies Mon-Thu: SAR, JOD.
  • *
* @author Benoit Xhenseval * @since 1.4.0 */ public class DefaultCurrencyCalculatorConfig implements CurrencyCalculatorConfig { private Map> currenciesSubjectToCrossCcyForT1 = new HashMap>(); private Map workingWeeks = new HashMap(); public DefaultCurrencyCalculatorConfig() { super(); final Set subjectToUsd = new HashSet(); subjectToUsd.add("MXN"); subjectToUsd.add("CLP"); subjectToUsd.add("ARS"); currenciesSubjectToCrossCcyForT1.put(CurrencyDateCalculator.USD_CODE, subjectToUsd); workingWeeks.put("AED", WorkingWeek.ARABIC_WEEK); workingWeeks.put("BHD", WorkingWeek.ARABIC_WEEK); workingWeeks.put("EGP", WorkingWeek.ARABIC_WEEK); workingWeeks.put("KWD", WorkingWeek.ARABIC_WEEK); workingWeeks.put("OMR", WorkingWeek.ARABIC_WEEK); workingWeeks.put("QAR", WorkingWeek.ARABIC_WEEK); workingWeeks.put("SAR", WorkingWeek.ARABIC_WEEK.intersection(WorkingWeek.DEFAULT)); workingWeeks.put("JOD", WorkingWeek.ARABIC_WEEK.intersection(WorkingWeek.DEFAULT)); } /** * Will take a copy of a non null set but doing so by replacing the internal one in one go for consistency. */ public void setCurrenciesSubjectToCrossCcyForT1(final Map> currenciesSubjectToCrossCcyForT1) { final Map> copy = new HashMap>(); if (currenciesSubjectToCrossCcyForT1 != null) { copy.putAll(currenciesSubjectToCrossCcyForT1); } this.currenciesSubjectToCrossCcyForT1 = copy; } /** * Will take a copy of a non null map but doing so by replacing the internal one in one go for consistency. */ public void setWorkingWeeks(final Map workingWeeks) { final Map ww = new HashMap(); ww.putAll(workingWeeks); this.workingWeeks = ww; } /** * @return an unmodifiable set of currencies. */ public Set getCurrenciesSubjectToCrossCcyForT1(final String crossCcy) { final Set s = currenciesSubjectToCrossCcyForT1.get(crossCcy); return s != null ? Collections.unmodifiableSet(s) : Collections. emptySet(); } /** * Return a default Mon-Fri for most, but some might be Sun-Thu (Arabic countries). * @param currency * @return the WorkingWeek registered for this currency other the default Mon-Fri. */ public WorkingWeek getWorkingWeek(final String currency) { final WorkingWeek workingWeek = workingWeeks.get(currency); return workingWeek != null ? workingWeek : WorkingWeek.DEFAULT; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy