/** * Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies * <p/> * Please see distribution for license. */ package com.opengamma.sesame.component; import java.util.LinkedHashMap; import java.util.Map; 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.opengamma.component.ComponentRepository; import com.opengamma.component.factory.AbstractComponentFactory; import com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource; import com.opengamma.sesame.marketdata.HistoricalMarketDataFactory; /** * Component factory for creating a {@link HistoricalMarketDataFactory}. */ @BeanDefinition public class HistoricalMarketDataFactoryComponentFactory extends AbstractComponentFactory { /** Name under which the components will be published. */ @PropertyDefinition(validate = "notEmpty") private String _classifier; /** A source of historical time series. */ @PropertyDefinition(validate = "notNull") private HistoricalTimeSeriesSource _timeSeriesSource; /** The data source name used when querying time series. */ @PropertyDefinition(validate = "notEmpty") private String _timeSeriesDataSource; /** The data provider name used when querying time series. */ @PropertyDefinition private String _timeSeriesDataProvider; @Override public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception { HistoricalMarketDataFactory marketDataFactory = new HistoricalMarketDataFactory(_timeSeriesSource, _timeSeriesDataSource, _timeSeriesDataProvider); repo.registerComponent(HistoricalMarketDataFactory.class, _classifier, marketDataFactory); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code HistoricalMarketDataFactoryComponentFactory}. * @return the meta-bean, not null */ public static HistoricalMarketDataFactoryComponentFactory.Meta meta() { return HistoricalMarketDataFactoryComponentFactory.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(HistoricalMarketDataFactoryComponentFactory.Meta.INSTANCE); } @Override public HistoricalMarketDataFactoryComponentFactory.Meta metaBean() { return HistoricalMarketDataFactoryComponentFactory.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets name under which the components will be published. * @return the value of the property, not empty */ public String getClassifier() { return _classifier; } /** * Sets name under which the components will be published. * @param classifier the new value of the property, not empty */ public void setClassifier(String classifier) { JodaBeanUtils.notEmpty(classifier, "classifier"); this._classifier = classifier; } /** * Gets the the {@code classifier} property. * @return the property, not null */ public final Property<String> classifier() { return metaBean().classifier().createProperty(this); } //----------------------------------------------------------------------- /** * Gets a source of historical time series. * @return the value of the property, not null */ public HistoricalTimeSeriesSource getTimeSeriesSource() { return _timeSeriesSource; } /** * Sets a source of historical time series. * @param timeSeriesSource the new value of the property, not null */ public void setTimeSeriesSource(HistoricalTimeSeriesSource timeSeriesSource) { JodaBeanUtils.notNull(timeSeriesSource, "timeSeriesSource"); this._timeSeriesSource = timeSeriesSource; } /** * Gets the the {@code timeSeriesSource} property. * @return the property, not null */ public final Property<HistoricalTimeSeriesSource> timeSeriesSource() { return metaBean().timeSeriesSource().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the data source name used when querying time series. * @return the value of the property, not empty */ public String getTimeSeriesDataSource() { return _timeSeriesDataSource; } /** * Sets the data source name used when querying time series. * @param timeSeriesDataSource the new value of the property, not empty */ public void setTimeSeriesDataSource(String timeSeriesDataSource) { JodaBeanUtils.notEmpty(timeSeriesDataSource, "timeSeriesDataSource"); this._timeSeriesDataSource = timeSeriesDataSource; } /** * Gets the the {@code timeSeriesDataSource} property. * @return the property, not null */ public final Property<String> timeSeriesDataSource() { return metaBean().timeSeriesDataSource().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the data provider name used when querying time series. * @return the value of the property */ public String getTimeSeriesDataProvider() { return _timeSeriesDataProvider; } /** * Sets the data provider name used when querying time series. * @param timeSeriesDataProvider the new value of the property */ public void setTimeSeriesDataProvider(String timeSeriesDataProvider) { this._timeSeriesDataProvider = timeSeriesDataProvider; } /** * Gets the the {@code timeSeriesDataProvider} property. * @return the property, not null */ public final Property<String> timeSeriesDataProvider() { return metaBean().timeSeriesDataProvider().createProperty(this); } //----------------------------------------------------------------------- @Override public HistoricalMarketDataFactoryComponentFactory clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { HistoricalMarketDataFactoryComponentFactory other = (HistoricalMarketDataFactoryComponentFactory) obj; return JodaBeanUtils.equal(getClassifier(), other.getClassifier()) && JodaBeanUtils.equal(getTimeSeriesSource(), other.getTimeSeriesSource()) && JodaBeanUtils.equal(getTimeSeriesDataSource(), other.getTimeSeriesDataSource()) && JodaBeanUtils.equal(getTimeSeriesDataProvider(), other.getTimeSeriesDataProvider()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getClassifier()); hash = hash * 31 + JodaBeanUtils.hashCode(getTimeSeriesSource()); hash = hash * 31 + JodaBeanUtils.hashCode(getTimeSeriesDataSource()); hash = hash * 31 + JodaBeanUtils.hashCode(getTimeSeriesDataProvider()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(160); buf.append("HistoricalMarketDataFactoryComponentFactory{"); 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("classifier").append('=').append(JodaBeanUtils.toString(getClassifier())).append(',').append(' '); buf.append("timeSeriesSource").append('=').append(JodaBeanUtils.toString(getTimeSeriesSource())).append(',').append(' '); buf.append("timeSeriesDataSource").append('=').append(JodaBeanUtils.toString(getTimeSeriesDataSource())).append(',').append(' '); buf.append("timeSeriesDataProvider").append('=').append(JodaBeanUtils.toString(getTimeSeriesDataProvider())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code HistoricalMarketDataFactoryComponentFactory}. */ public static class Meta extends AbstractComponentFactory.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code classifier} property. */ private final MetaProperty<String> _classifier = DirectMetaProperty.ofReadWrite( this, "classifier", HistoricalMarketDataFactoryComponentFactory.class, String.class); /** * The meta-property for the {@code timeSeriesSource} property. */ private final MetaProperty<HistoricalTimeSeriesSource> _timeSeriesSource = DirectMetaProperty.ofReadWrite( this, "timeSeriesSource", HistoricalMarketDataFactoryComponentFactory.class, HistoricalTimeSeriesSource.class); /** * The meta-property for the {@code timeSeriesDataSource} property. */ private final MetaProperty<String> _timeSeriesDataSource = DirectMetaProperty.ofReadWrite( this, "timeSeriesDataSource", HistoricalMarketDataFactoryComponentFactory.class, String.class); /** * The meta-property for the {@code timeSeriesDataProvider} property. */ private final MetaProperty<String> _timeSeriesDataProvider = DirectMetaProperty.ofReadWrite( this, "timeSeriesDataProvider", HistoricalMarketDataFactoryComponentFactory.class, String.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "classifier", "timeSeriesSource", "timeSeriesDataSource", "timeSeriesDataProvider"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -281470431: // classifier return _classifier; case 2131310815: // timeSeriesSource return _timeSeriesSource; case -2110575831: // timeSeriesDataSource return _timeSeriesDataSource; case 522337663: // timeSeriesDataProvider return _timeSeriesDataProvider; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends HistoricalMarketDataFactoryComponentFactory> builder() { return new DirectBeanBuilder<HistoricalMarketDataFactoryComponentFactory>(new HistoricalMarketDataFactoryComponentFactory()); } @Override public Class<? extends HistoricalMarketDataFactoryComponentFactory> beanType() { return HistoricalMarketDataFactoryComponentFactory.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code classifier} property. * @return the meta-property, not null */ public final MetaProperty<String> classifier() { return _classifier; } /** * The meta-property for the {@code timeSeriesSource} property. * @return the meta-property, not null */ public final MetaProperty<HistoricalTimeSeriesSource> timeSeriesSource() { return _timeSeriesSource; } /** * The meta-property for the {@code timeSeriesDataSource} property. * @return the meta-property, not null */ public final MetaProperty<String> timeSeriesDataSource() { return _timeSeriesDataSource; } /** * The meta-property for the {@code timeSeriesDataProvider} property. * @return the meta-property, not null */ public final MetaProperty<String> timeSeriesDataProvider() { return _timeSeriesDataProvider; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -281470431: // classifier return ((HistoricalMarketDataFactoryComponentFactory) bean).getClassifier(); case 2131310815: // timeSeriesSource return ((HistoricalMarketDataFactoryComponentFactory) bean).getTimeSeriesSource(); case -2110575831: // timeSeriesDataSource return ((HistoricalMarketDataFactoryComponentFactory) bean).getTimeSeriesDataSource(); case 522337663: // timeSeriesDataProvider return ((HistoricalMarketDataFactoryComponentFactory) bean).getTimeSeriesDataProvider(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -281470431: // classifier ((HistoricalMarketDataFactoryComponentFactory) bean).setClassifier((String) newValue); return; case 2131310815: // timeSeriesSource ((HistoricalMarketDataFactoryComponentFactory) bean).setTimeSeriesSource((HistoricalTimeSeriesSource) newValue); return; case -2110575831: // timeSeriesDataSource ((HistoricalMarketDataFactoryComponentFactory) bean).setTimeSeriesDataSource((String) newValue); return; case 522337663: // timeSeriesDataProvider ((HistoricalMarketDataFactoryComponentFactory) bean).setTimeSeriesDataProvider((String) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notEmpty(((HistoricalMarketDataFactoryComponentFactory) bean)._classifier, "classifier"); JodaBeanUtils.notNull(((HistoricalMarketDataFactoryComponentFactory) bean)._timeSeriesSource, "timeSeriesSource"); JodaBeanUtils.notEmpty(((HistoricalMarketDataFactoryComponentFactory) bean)._timeSeriesDataSource, "timeSeriesDataSource"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }