CurrencyPairs implements Bean, UniqueIdentifiable, MutableUniqueIdentifiable { public CurrencyPair getCurrencyPair(final Currency currency1, final Currency currency2) { ArgumentChecker.notNull(currency1, "currency1"); ArgumentChecker.notNull(currency2, "currency2"); final CurrencyPair pair = CurrencyPair.of(currency1, currency2); if (_pairs.contains(pair)) { return pair; } final CurrencyPair inverse = pair.inverse(); if (_pairs.contains(inverse)) { return inverse; } return null; } private  CurrencyPairs(); private  CurrencyPairs(final Set<CurrencyPair> pairs); static CurrencyPairs of(final Set<CurrencyPair> pairs); void setPairs(final Set<CurrencyPair> pairs); CurrencyPair getCurrencyPair(final Currency currency1, final Currency currency2); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); static CurrencyPairs.Meta meta(); @Override CurrencyPairs.Meta metaBean(); @Override Property<R> property(String propertyName); @Override Set<String> propertyNames(); Set<CurrencyPair> getPairs(); Property<Set<CurrencyPair>> pairs(); UniqueId getUniqueId(); void setUniqueId(UniqueId uniqueId); Property<UniqueId> uniqueId(); @Override CurrencyPairs clone(); static final ComputationTargetType TYPE; static final String DEFAULT_CURRENCY_PAIRS; }
@Test public void getCurrencyPair() { CurrencyPair eurUsd = CurrencyPair.of(Currency.EUR, Currency.USD); CurrencyPair gbpUsd = CurrencyPair.of(Currency.GBP, Currency.USD); assertEquals(eurUsd, _pairs.getCurrencyPair(Currency.USD, Currency.EUR)); assertEquals(eurUsd, _pairs.getCurrencyPair(Currency.EUR, Currency.USD)); assertEquals(gbpUsd, _pairs.getCurrencyPair(Currency.GBP, Currency.USD)); assertEquals(gbpUsd, _pairs.getCurrencyPair(Currency.USD, Currency.GBP)); }