/** * Copyright (C) 2014 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.sesame.marketdata; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import org.joda.beans.Bean; import org.joda.beans.BeanDefinition; import org.joda.beans.ImmutableBean; 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.DirectFieldsBeanBuilder; import org.joda.beans.impl.direct.DirectMetaBean; import org.joda.beans.impl.direct.DirectMetaProperty; import org.joda.beans.impl.direct.DirectMetaPropertyMap; import com.opengamma.id.ExternalIdBundle; /** * Simple bean representing the data used when requesting a historical time series. */ @BeanDefinition public class HtsRequestKey implements ImmutableBean { /** * Identifier for the time series. */ @PropertyDefinition(validate = "notNull") private final ExternalIdBundle _identifierBundle; /** * Data source for the time series, not required. */ @PropertyDefinition private final String _dataSource; /** * Provider for the time series, not required. */ @PropertyDefinition private final String _dataProvider; /** * Data field for the time series. */ @PropertyDefinition(validate = "notNull") private final String _dataField; /** * Create a new HTS Request key. * * @param identifierBundle identifier for the time series * @param dataSource data source for the time series, not required * @param dataProvider provider for the time series, not required * @param dataField data field for the time series * @return the HTS key */ public static HtsRequestKey of(ExternalIdBundle identifierBundle, String dataSource, String dataProvider, String dataField) { return new HtsRequestKey( builder() .identifierBundle(identifierBundle) .dataSource(dataSource) .dataProvider(dataProvider) .dataField(dataField)); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code HtsRequestKey}. * @return the meta-bean, not null */ public static HtsRequestKey.Meta meta() { return HtsRequestKey.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(HtsRequestKey.Meta.INSTANCE); } /** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static HtsRequestKey.Builder builder() { return new HtsRequestKey.Builder(); } /** * Restricted constructor. * @param builder the builder to copy from, not null */ protected HtsRequestKey(HtsRequestKey.Builder builder) { JodaBeanUtils.notNull(builder._identifierBundle, "identifierBundle"); JodaBeanUtils.notNull(builder._dataField, "dataField"); this._identifierBundle = builder._identifierBundle; this._dataSource = builder._dataSource; this._dataProvider = builder._dataProvider; this._dataField = builder._dataField; } @Override public HtsRequestKey.Meta metaBean() { return HtsRequestKey.Meta.INSTANCE; } @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 identifier for the time series. * @return the value of the property, not null */ public ExternalIdBundle getIdentifierBundle() { return _identifierBundle; } //----------------------------------------------------------------------- /** * Gets data source for the time series, not required. * @return the value of the property */ public String getDataSource() { return _dataSource; } //----------------------------------------------------------------------- /** * Gets provider for the time series, not required. * @return the value of the property */ public String getDataProvider() { return _dataProvider; } //----------------------------------------------------------------------- /** * Gets data field for the time series. * @return the value of the property, not null */ public String getDataField() { return _dataField; } //----------------------------------------------------------------------- /** * Returns a builder that allows this bean to be mutated. * @return the mutable builder, not null */ public Builder toBuilder() { return new Builder(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { HtsRequestKey other = (HtsRequestKey) obj; return JodaBeanUtils.equal(getIdentifierBundle(), other.getIdentifierBundle()) && JodaBeanUtils.equal(getDataSource(), other.getDataSource()) && JodaBeanUtils.equal(getDataProvider(), other.getDataProvider()) && JodaBeanUtils.equal(getDataField(), other.getDataField()); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(getIdentifierBundle()); hash = hash * 31 + JodaBeanUtils.hashCode(getDataSource()); hash = hash * 31 + JodaBeanUtils.hashCode(getDataProvider()); hash = hash * 31 + JodaBeanUtils.hashCode(getDataField()); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("HtsRequestKey{"); int len = buf.length(); toString(buf); if (buf.length() > len) { buf.setLength(buf.length() - 2); } buf.append('}'); return buf.toString(); } protected void toString(StringBuilder buf) { buf.append("identifierBundle").append('=').append(JodaBeanUtils.toString(getIdentifierBundle())).append(',').append(' '); buf.append("dataSource").append('=').append(JodaBeanUtils.toString(getDataSource())).append(',').append(' '); buf.append("dataProvider").append('=').append(JodaBeanUtils.toString(getDataProvider())).append(',').append(' '); buf.append("dataField").append('=').append(JodaBeanUtils.toString(getDataField())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code HtsRequestKey}. */ public static class Meta extends DirectMetaBean { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code identifierBundle} property. */ private final MetaProperty<ExternalIdBundle> _identifierBundle = DirectMetaProperty.ofImmutable( this, "identifierBundle", HtsRequestKey.class, ExternalIdBundle.class); /** * The meta-property for the {@code dataSource} property. */ private final MetaProperty<String> _dataSource = DirectMetaProperty.ofImmutable( this, "dataSource", HtsRequestKey.class, String.class); /** * The meta-property for the {@code dataProvider} property. */ private final MetaProperty<String> _dataProvider = DirectMetaProperty.ofImmutable( this, "dataProvider", HtsRequestKey.class, String.class); /** * The meta-property for the {@code dataField} property. */ private final MetaProperty<String> _dataField = DirectMetaProperty.ofImmutable( this, "dataField", HtsRequestKey.class, String.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, null, "identifierBundle", "dataSource", "dataProvider", "dataField"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -325523829: // identifierBundle return _identifierBundle; case 1272470629: // dataSource return _dataSource; case 339742651: // dataProvider return _dataProvider; case -386794640: // dataField return _dataField; } return super.metaPropertyGet(propertyName); } @Override public HtsRequestKey.Builder builder() { return new HtsRequestKey.Builder(); } @Override public Class<? extends HtsRequestKey> beanType() { return HtsRequestKey.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code identifierBundle} property. * @return the meta-property, not null */ public final MetaProperty<ExternalIdBundle> identifierBundle() { return _identifierBundle; } /** * The meta-property for the {@code dataSource} property. * @return the meta-property, not null */ public final MetaProperty<String> dataSource() { return _dataSource; } /** * The meta-property for the {@code dataProvider} property. * @return the meta-property, not null */ public final MetaProperty<String> dataProvider() { return _dataProvider; } /** * The meta-property for the {@code dataField} property. * @return the meta-property, not null */ public final MetaProperty<String> dataField() { return _dataField; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -325523829: // identifierBundle return ((HtsRequestKey) bean).getIdentifierBundle(); case 1272470629: // dataSource return ((HtsRequestKey) bean).getDataSource(); case 339742651: // dataProvider return ((HtsRequestKey) bean).getDataProvider(); case -386794640: // dataField return ((HtsRequestKey) bean).getDataField(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { metaProperty(propertyName); if (quiet) { return; } throw new UnsupportedOperationException("Property cannot be written: " + propertyName); } } //----------------------------------------------------------------------- /** * The bean-builder for {@code HtsRequestKey}. */ public static class Builder extends DirectFieldsBeanBuilder<HtsRequestKey> { private ExternalIdBundle _identifierBundle; private String _dataSource; private String _dataProvider; private String _dataField; /** * Restricted constructor. */ protected Builder() { } /** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ protected Builder(HtsRequestKey beanToCopy) { this._identifierBundle = beanToCopy.getIdentifierBundle(); this._dataSource = beanToCopy.getDataSource(); this._dataProvider = beanToCopy.getDataProvider(); this._dataField = beanToCopy.getDataField(); } //----------------------------------------------------------------------- @Override public Object get(String propertyName) { switch (propertyName.hashCode()) { case -325523829: // identifierBundle return _identifierBundle; case 1272470629: // dataSource return _dataSource; case 339742651: // dataProvider return _dataProvider; case -386794640: // dataField return _dataField; default: throw new NoSuchElementException("Unknown property: " + propertyName); } } @Override public Builder set(String propertyName, Object newValue) { switch (propertyName.hashCode()) { case -325523829: // identifierBundle this._identifierBundle = (ExternalIdBundle) newValue; break; case 1272470629: // dataSource this._dataSource = (String) newValue; break; case 339742651: // dataProvider this._dataProvider = (String) newValue; break; case -386794640: // dataField this._dataField = (String) newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return this; } @Override public Builder set(MetaProperty<?> property, Object value) { super.set(property, value); return this; } @Override public Builder setString(String propertyName, String value) { setString(meta().metaProperty(propertyName), value); return this; } @Override public Builder setString(MetaProperty<?> property, String value) { super.setString(property, value); return this; } @Override public Builder setAll(Map<String, ? extends Object> propertyValueMap) { super.setAll(propertyValueMap); return this; } @Override public HtsRequestKey build() { return new HtsRequestKey(this); } //----------------------------------------------------------------------- /** * Sets the {@code identifierBundle} property in the builder. * @param identifierBundle the new value, not null * @return this, for chaining, not null */ public Builder identifierBundle(ExternalIdBundle identifierBundle) { JodaBeanUtils.notNull(identifierBundle, "identifierBundle"); this._identifierBundle = identifierBundle; return this; } /** * Sets the {@code dataSource} property in the builder. * @param dataSource the new value * @return this, for chaining, not null */ public Builder dataSource(String dataSource) { this._dataSource = dataSource; return this; } /** * Sets the {@code dataProvider} property in the builder. * @param dataProvider the new value * @return this, for chaining, not null */ public Builder dataProvider(String dataProvider) { this._dataProvider = dataProvider; return this; } /** * Sets the {@code dataField} property in the builder. * @param dataField the new value, not null * @return this, for chaining, not null */ public Builder dataField(String dataField) { JodaBeanUtils.notNull(dataField, "dataField"); this._dataField = dataField; return this; } //----------------------------------------------------------------------- @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("HtsRequestKey.Builder{"); int len = buf.length(); toString(buf); if (buf.length() > len) { buf.setLength(buf.length() - 2); } buf.append('}'); return buf.toString(); } protected void toString(StringBuilder buf) { buf.append("identifierBundle").append('=').append(JodaBeanUtils.toString(_identifierBundle)).append(',').append(' '); buf.append("dataSource").append('=').append(JodaBeanUtils.toString(_dataSource)).append(',').append(' '); buf.append("dataProvider").append('=').append(JodaBeanUtils.toString(_dataProvider)).append(',').append(' '); buf.append("dataField").append('=').append(JodaBeanUtils.toString(_dataField)).append(',').append(' '); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }