/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.component.factory.infrastructure;
import com.opengamma.component.ComponentInfo;
import com.opengamma.component.ComponentRepository;
import com.opengamma.component.factory.AbstractComponentFactory;
import com.opengamma.util.fudgemsg.OpenGammaFudgeContext;
import org.fudgemsg.FudgeContext;
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 java.util.LinkedHashMap;
import java.util.Map;
/**
* Component Factory for a singleton FudgeContext.
*
*/
@BeanDefinition
public class FudgeContextComponentFactory extends AbstractComponentFactory {
@PropertyDefinition(validate = "notNull")
private String _classifier;
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
final ComponentInfo info = new ComponentInfo(FudgeContext.class, getClassifier());
final FudgeContext component = initFudgeContext();
repo.registerComponent(info, component);
}
protected final FudgeContext initFudgeContext() {
return OpenGammaFudgeContext.getInstance();
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code FudgeContextComponentFactory}.
* @return the meta-bean, not null
*/
public static FudgeContextComponentFactory.Meta meta() {
return FudgeContextComponentFactory.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(FudgeContextComponentFactory.Meta.INSTANCE);
}
@Override
public FudgeContextComponentFactory.Meta metaBean() {
return FudgeContextComponentFactory.Meta.INSTANCE;
}
@Override
protected Object propertyGet(String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -281470431: // classifier
return getClassifier();
}
return super.propertyGet(propertyName, quiet);
}
@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -281470431: // classifier
setClassifier((String) newValue);
return;
}
super.propertySet(propertyName, newValue, quiet);
}
@Override
protected void validate() {
JodaBeanUtils.notNull(_classifier, "classifier");
super.validate();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
FudgeContextComponentFactory other = (FudgeContextComponentFactory) obj;
return JodaBeanUtils.equal(getClassifier(), other.getClassifier()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash += hash * 31 + JodaBeanUtils.hashCode(getClassifier());
return hash ^ super.hashCode();
}
//-----------------------------------------------------------------------
/**
* Gets the classifier.
* @return the value of the property, not null
*/
public String getClassifier() {
return _classifier;
}
/**
* Sets the classifier.
* @param classifier the new value of the property, not null
*/
public void setClassifier(String classifier) {
JodaBeanUtils.notNull(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);
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code FudgeContextComponentFactory}.
*/
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", FudgeContextComponentFactory.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"classifier");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -281470431: // classifier
return _classifier;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends FudgeContextComponentFactory> builder() {
return new DirectBeanBuilder<FudgeContextComponentFactory>(new FudgeContextComponentFactory());
}
@Override
public Class<? extends FudgeContextComponentFactory> beanType() {
return FudgeContextComponentFactory.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;
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}