/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.analytics.curve;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.google.common.collect.Sets;
import com.opengamma.analytics.financial.legalentity.LegalEntity;
import com.opengamma.analytics.financial.legalentity.LegalEntityCombiningFilter;
import com.opengamma.analytics.financial.legalentity.LegalEntityFilter;
import com.opengamma.analytics.financial.legalentity.LegalEntityRegion;
import com.opengamma.analytics.financial.legalentity.LegalEntityShortName;
import com.opengamma.util.ArgumentChecker;
import com.opengamma.util.i18n.Country;
import com.opengamma.util.money.Currency;
/**
* Configuration object for curves that are to be used as an issuer curve.
*/
@BeanDefinition
public class IssuerCurveTypeConfiguration extends CurveTypeConfiguration {
/** Serialization version */
private static final long serialVersionUID = 1L;
/**
* The set of keys for the issuer curve.
*/
@PropertyDefinition(validate = "notNull")
private Set<Object> _keys;
/**
* The legal entity filters.
*/
@PropertyDefinition(validate = "notNull")
private LegalEntityCombiningFilter _filters;
/**
* The issuer name.
* @deprecated This field is no longer used.
*/
@Deprecated
@PropertyDefinition
private String _issuerName;
/**
* The underlying reference.
* @deprecated This field is no longer used.
*/
@Deprecated
@PropertyDefinition
private String _underlyingReference;
/**
* For the fudge builder
*/
/* package */ IssuerCurveTypeConfiguration() {
super();
}
/**
* @param issuerName The issuer name, not null
* @param underlyingReference The underlying reference (e.g. a currency) for the curve
* @deprecated This constructor can only be used to construct an (issuer name, currency) key for
* the issuer curve.
*/
@Deprecated
public IssuerCurveTypeConfiguration(final String issuerName, final String underlyingReference) {
super();
final Set<Object> keys = Sets.<Object>newHashSet(issuerName, underlyingReference);
final Set<LegalEntityFilter<LegalEntity>> filterSet = new HashSet<>();
filterSet.add(new LegalEntityRegion(false, false, Collections.<Country>emptySet(), true, Collections.singleton(Currency.of(underlyingReference))));
filterSet.add(new LegalEntityShortName());
final LegalEntityCombiningFilter filters = new LegalEntityCombiningFilter(filterSet);
setKeys(keys);
setFilters(filters);
}
/**
* @param keys The keys for the curves, not null
* @param filters The legal entity filters, not null
*/
public IssuerCurveTypeConfiguration(final Set<Object> keys, final Set<LegalEntityFilter<LegalEntity>> filters) {
super();
ArgumentChecker.notNull(keys, "keys");
ArgumentChecker.notNull(filters, "filters");
setKeys(keys);
setFilters(new LegalEntityCombiningFilter(filters));
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code IssuerCurveTypeConfiguration}.
* @return the meta-bean, not null
*/
public static IssuerCurveTypeConfiguration.Meta meta() {
return IssuerCurveTypeConfiguration.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(IssuerCurveTypeConfiguration.Meta.INSTANCE);
}
@Override
public IssuerCurveTypeConfiguration.Meta metaBean() {
return IssuerCurveTypeConfiguration.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the set of keys for the issuer curve.
* @return the value of the property, not null
*/
public Set<Object> getKeys() {
return _keys;
}
/**
* Sets the set of keys for the issuer curve.
* @param keys the new value of the property, not null
*/
public void setKeys(Set<Object> keys) {
JodaBeanUtils.notNull(keys, "keys");
this._keys = keys;
}
/**
* Gets the the {@code keys} property.
* @return the property, not null
*/
public final Property<Set<Object>> keys() {
return metaBean().keys().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the legal entity filters.
* @return the value of the property, not null
*/
public LegalEntityCombiningFilter getFilters() {
return _filters;
}
/**
* Sets the legal entity filters.
* @param filters the new value of the property, not null
*/
public void setFilters(LegalEntityCombiningFilter filters) {
JodaBeanUtils.notNull(filters, "filters");
this._filters = filters;
}
/**
* Gets the the {@code filters} property.
* @return the property, not null
*/
public final Property<LegalEntityCombiningFilter> filters() {
return metaBean().filters().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the issuer name.
* @deprecated This field is no longer used.
* @return the value of the property
*/
@Deprecated
public String getIssuerName() {
return _issuerName;
}
/**
* Sets the issuer name.
* @deprecated This field is no longer used.
* @param issuerName the new value of the property
*/
@Deprecated
public void setIssuerName(String issuerName) {
this._issuerName = issuerName;
}
/**
* Gets the the {@code issuerName} property.
* @deprecated This field is no longer used.
* @return the property, not null
*/
@Deprecated
public final Property<String> issuerName() {
return metaBean().issuerName().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the underlying reference.
* @deprecated This field is no longer used.
* @return the value of the property
*/
@Deprecated
public String getUnderlyingReference() {
return _underlyingReference;
}
/**
* Sets the underlying reference.
* @deprecated This field is no longer used.
* @param underlyingReference the new value of the property
*/
@Deprecated
public void setUnderlyingReference(String underlyingReference) {
this._underlyingReference = underlyingReference;
}
/**
* Gets the the {@code underlyingReference} property.
* @deprecated This field is no longer used.
* @return the property, not null
*/
@Deprecated
public final Property<String> underlyingReference() {
return metaBean().underlyingReference().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public IssuerCurveTypeConfiguration clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
IssuerCurveTypeConfiguration other = (IssuerCurveTypeConfiguration) obj;
return JodaBeanUtils.equal(getKeys(), other.getKeys()) &&
JodaBeanUtils.equal(getFilters(), other.getFilters()) &&
JodaBeanUtils.equal(getIssuerName(), other.getIssuerName()) &&
JodaBeanUtils.equal(getUnderlyingReference(), other.getUnderlyingReference()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getKeys());
hash = hash * 31 + JodaBeanUtils.hashCode(getFilters());
hash = hash * 31 + JodaBeanUtils.hashCode(getIssuerName());
hash = hash * 31 + JodaBeanUtils.hashCode(getUnderlyingReference());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("IssuerCurveTypeConfiguration{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
@Override
protected void toString(StringBuilder buf) {
super.toString(buf);
buf.append("keys").append('=').append(JodaBeanUtils.toString(getKeys())).append(',').append(' ');
buf.append("filters").append('=').append(JodaBeanUtils.toString(getFilters())).append(',').append(' ');
buf.append("issuerName").append('=').append(JodaBeanUtils.toString(getIssuerName())).append(',').append(' ');
buf.append("underlyingReference").append('=').append(JodaBeanUtils.toString(getUnderlyingReference())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code IssuerCurveTypeConfiguration}.
*/
public static class Meta extends CurveTypeConfiguration.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code keys} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<Set<Object>> _keys = DirectMetaProperty.ofReadWrite(
this, "keys", IssuerCurveTypeConfiguration.class, (Class) Set.class);
/**
* The meta-property for the {@code filters} property.
*/
private final MetaProperty<LegalEntityCombiningFilter> _filters = DirectMetaProperty.ofReadWrite(
this, "filters", IssuerCurveTypeConfiguration.class, LegalEntityCombiningFilter.class);
/**
* The meta-property for the {@code issuerName} property.
*/
private final MetaProperty<String> _issuerName = DirectMetaProperty.ofReadWrite(
this, "issuerName", IssuerCurveTypeConfiguration.class, String.class);
/**
* The meta-property for the {@code underlyingReference} property.
*/
private final MetaProperty<String> _underlyingReference = DirectMetaProperty.ofReadWrite(
this, "underlyingReference", IssuerCurveTypeConfiguration.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"keys",
"filters",
"issuerName",
"underlyingReference");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 3288564: // keys
return _keys;
case -854547461: // filters
return _filters;
case 1459772644: // issuerName
return _issuerName;
case -1415245714: // underlyingReference
return _underlyingReference;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends IssuerCurveTypeConfiguration> builder() {
return new DirectBeanBuilder<IssuerCurveTypeConfiguration>(new IssuerCurveTypeConfiguration());
}
@Override
public Class<? extends IssuerCurveTypeConfiguration> beanType() {
return IssuerCurveTypeConfiguration.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code keys} property.
* @return the meta-property, not null
*/
public final MetaProperty<Set<Object>> keys() {
return _keys;
}
/**
* The meta-property for the {@code filters} property.
* @return the meta-property, not null
*/
public final MetaProperty<LegalEntityCombiningFilter> filters() {
return _filters;
}
/**
* The meta-property for the {@code issuerName} property.
* @deprecated This field is no longer used.
* @return the meta-property, not null
*/
@Deprecated
public final MetaProperty<String> issuerName() {
return _issuerName;
}
/**
* The meta-property for the {@code underlyingReference} property.
* @deprecated This field is no longer used.
* @return the meta-property, not null
*/
@Deprecated
public final MetaProperty<String> underlyingReference() {
return _underlyingReference;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 3288564: // keys
return ((IssuerCurveTypeConfiguration) bean).getKeys();
case -854547461: // filters
return ((IssuerCurveTypeConfiguration) bean).getFilters();
case 1459772644: // issuerName
return ((IssuerCurveTypeConfiguration) bean).getIssuerName();
case -1415245714: // underlyingReference
return ((IssuerCurveTypeConfiguration) bean).getUnderlyingReference();
}
return super.propertyGet(bean, propertyName, quiet);
}
@SuppressWarnings("unchecked")
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 3288564: // keys
((IssuerCurveTypeConfiguration) bean).setKeys((Set<Object>) newValue);
return;
case -854547461: // filters
((IssuerCurveTypeConfiguration) bean).setFilters((LegalEntityCombiningFilter) newValue);
return;
case 1459772644: // issuerName
((IssuerCurveTypeConfiguration) bean).setIssuerName((String) newValue);
return;
case -1415245714: // underlyingReference
((IssuerCurveTypeConfiguration) bean).setUnderlyingReference((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((IssuerCurveTypeConfiguration) bean)._keys, "keys");
JodaBeanUtils.notNull(((IssuerCurveTypeConfiguration) bean)._filters, "filters");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}