/** * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.strata.measure.rate; import java.io.Serializable; import java.util.Set; import org.joda.beans.BeanDefinition; import org.joda.beans.ImmutableBean; import org.joda.beans.JodaBeanUtils; import org.joda.beans.MetaBean; import org.joda.beans.Property; import org.joda.beans.PropertyDefinition; import org.joda.beans.impl.light.LightMetaBean; import com.opengamma.strata.basics.currency.FxRateProvider; import com.opengamma.strata.data.FxMatrixId; import com.opengamma.strata.data.MarketData; /** * The matrix FX rate lookup. */ @BeanDefinition(style = "light", constructorScope = "package") final class MatrixFxRateLookup implements FxRateLookup, ImmutableBean, Serializable { /** * The singleton instance. */ static final MatrixFxRateLookup DEFAULT = new MatrixFxRateLookup(FxMatrixId.standard()); /** * The FX matrix identifier. */ @PropertyDefinition(validate = "notNull") private final FxMatrixId matrixId; //------------------------------------------------------------------------- @Override public FxRateProvider fxRateProvider(MarketData marketData) { return marketData.getValue(matrixId); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code MatrixFxRateLookup}. */ private static MetaBean META_BEAN = LightMetaBean.of(MatrixFxRateLookup.class); /** * The meta-bean for {@code MatrixFxRateLookup}. * @return the meta-bean, not null */ public static MetaBean meta() { return META_BEAN; } static { JodaBeanUtils.registerMetaBean(META_BEAN); } /** * The serialization version id. */ private static final long serialVersionUID = 1L; /** * Creates an instance. * @param matrixId the value of the property, not null */ MatrixFxRateLookup( FxMatrixId matrixId) { JodaBeanUtils.notNull(matrixId, "matrixId"); this.matrixId = matrixId; } @Override public MetaBean metaBean() { return META_BEAN; } @Override public <R> Property<R> property(String propertyName) { return metaBean().<R>metaProperty(propertyName).createProperty(this); } @Override public Set<String> propertyNames() { return metaBean().metaPropertyMap().keySet(); } //----------------------------------------------------------------------- /** * Gets the FX matrix identifier. * @return the value of the property, not null */ public FxMatrixId getMatrixId() { return matrixId; } //----------------------------------------------------------------------- @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { MatrixFxRateLookup other = (MatrixFxRateLookup) obj; return JodaBeanUtils.equal(matrixId, other.matrixId); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(matrixId); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(64); buf.append("MatrixFxRateLookup{"); buf.append("matrixId").append('=').append(JodaBeanUtils.toString(matrixId)); buf.append('}'); return buf.toString(); } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }