/**
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.bbg.component;
import java.util.Map;
import net.sf.ehcache.CacheManager;
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.bbg.BloombergConnector;
import com.opengamma.bbg.BloombergConstants;
import com.opengamma.bbg.historicaltimeseries.BloombergHistoricalTimeSeriesProvider;
import com.opengamma.component.ComponentRepository;
import com.opengamma.component.factory.provider.HistoricalTimeSeriesProviderComponentFactory;
import com.opengamma.provider.historicaltimeseries.HistoricalTimeSeriesProvider;
import com.opengamma.provider.historicaltimeseries.impl.EHCachingHistoricalTimeSeriesProvider;
/**
* Component factory for the Bloomberg time-series provider.
*/
@BeanDefinition
public class BloombergHistoricalTimeSeriesProviderComponentFactory extends HistoricalTimeSeriesProviderComponentFactory {
/**
* The Bloomberg connector.
*/
@PropertyDefinition(validate = "notNull")
private BloombergConnector _bloombergConnector;
/**
* The optional cache manager.
* Caching will be added if this field is set.
*/
@PropertyDefinition
private CacheManager _cacheManager;
//-------------------------------------------------------------------------
@Override
protected HistoricalTimeSeriesProvider initHistoricalTimeSeriesProvider(ComponentRepository repo) {
BloombergHistoricalTimeSeriesProvider provider = new BloombergHistoricalTimeSeriesProvider(getBloombergConnector());
if (getCacheManager() == null) {
return provider;
}
repo.registerLifecycle(provider);
return new EHCachingHistoricalTimeSeriesProvider(provider, getCacheManager());
}
@Override
protected String getAcceptedTypes() {
return BloombergConstants.BLOOMBERG_DATA_SOURCE_NAME;
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code BloombergHistoricalTimeSeriesProviderComponentFactory}.
* @return the meta-bean, not null
*/
public static BloombergHistoricalTimeSeriesProviderComponentFactory.Meta meta() {
return BloombergHistoricalTimeSeriesProviderComponentFactory.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(BloombergHistoricalTimeSeriesProviderComponentFactory.Meta.INSTANCE);
}
@Override
public BloombergHistoricalTimeSeriesProviderComponentFactory.Meta metaBean() {
return BloombergHistoricalTimeSeriesProviderComponentFactory.Meta.INSTANCE;
}
@Override
protected Object propertyGet(String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 2061648978: // bloombergConnector
return getBloombergConnector();
case -1452875317: // cacheManager
return getCacheManager();
}
return super.propertyGet(propertyName, quiet);
}
@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 2061648978: // bloombergConnector
setBloombergConnector((BloombergConnector) newValue);
return;
case -1452875317: // cacheManager
setCacheManager((CacheManager) newValue);
return;
}
super.propertySet(propertyName, newValue, quiet);
}
@Override
protected void validate() {
JodaBeanUtils.notNull(_bloombergConnector, "bloombergConnector");
super.validate();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
BloombergHistoricalTimeSeriesProviderComponentFactory other = (BloombergHistoricalTimeSeriesProviderComponentFactory) obj;
return JodaBeanUtils.equal(getBloombergConnector(), other.getBloombergConnector()) &&
JodaBeanUtils.equal(getCacheManager(), other.getCacheManager()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash += hash * 31 + JodaBeanUtils.hashCode(getBloombergConnector());
hash += hash * 31 + JodaBeanUtils.hashCode(getCacheManager());
return hash ^ super.hashCode();
}
//-----------------------------------------------------------------------
/**
* Gets the Bloomberg connector.
* @return the value of the property, not null
*/
public BloombergConnector getBloombergConnector() {
return _bloombergConnector;
}
/**
* Sets the Bloomberg connector.
* @param bloombergConnector the new value of the property, not null
*/
public void setBloombergConnector(BloombergConnector bloombergConnector) {
JodaBeanUtils.notNull(bloombergConnector, "bloombergConnector");
this._bloombergConnector = bloombergConnector;
}
/**
* Gets the the {@code bloombergConnector} property.
* @return the property, not null
*/
public final Property<BloombergConnector> bloombergConnector() {
return metaBean().bloombergConnector().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the optional cache manager.
* Caching will be added if this field is set.
* @return the value of the property
*/
public CacheManager getCacheManager() {
return _cacheManager;
}
/**
* Sets the optional cache manager.
* Caching will be added if this field is set.
* @param cacheManager the new value of the property
*/
public void setCacheManager(CacheManager cacheManager) {
this._cacheManager = cacheManager;
}
/**
* Gets the the {@code cacheManager} property.
* Caching will be added if this field is set.
* @return the property, not null
*/
public final Property<CacheManager> cacheManager() {
return metaBean().cacheManager().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code BloombergHistoricalTimeSeriesProviderComponentFactory}.
*/
public static class Meta extends HistoricalTimeSeriesProviderComponentFactory.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code bloombergConnector} property.
*/
private final MetaProperty<BloombergConnector> _bloombergConnector = DirectMetaProperty.ofReadWrite(
this, "bloombergConnector", BloombergHistoricalTimeSeriesProviderComponentFactory.class, BloombergConnector.class);
/**
* The meta-property for the {@code cacheManager} property.
*/
private final MetaProperty<CacheManager> _cacheManager = DirectMetaProperty.ofReadWrite(
this, "cacheManager", BloombergHistoricalTimeSeriesProviderComponentFactory.class, CacheManager.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"bloombergConnector",
"cacheManager");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 2061648978: // bloombergConnector
return _bloombergConnector;
case -1452875317: // cacheManager
return _cacheManager;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends BloombergHistoricalTimeSeriesProviderComponentFactory> builder() {
return new DirectBeanBuilder<BloombergHistoricalTimeSeriesProviderComponentFactory>(new BloombergHistoricalTimeSeriesProviderComponentFactory());
}
@Override
public Class<? extends BloombergHistoricalTimeSeriesProviderComponentFactory> beanType() {
return BloombergHistoricalTimeSeriesProviderComponentFactory.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code bloombergConnector} property.
* @return the meta-property, not null
*/
public final MetaProperty<BloombergConnector> bloombergConnector() {
return _bloombergConnector;
}
/**
* The meta-property for the {@code cacheManager} property.
* @return the meta-property, not null
*/
public final MetaProperty<CacheManager> cacheManager() {
return _cacheManager;
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}