/**
* Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.sesame.web;
import com.opengamma.component.ComponentRepository;
import com.opengamma.component.factory.AbstractComponentFactory;
import com.opengamma.sesame.engine.ViewRunner;
import com.opengamma.sesame.marketdata.builders.MarketDataEnvironmentFactory;
import com.opengamma.sesame.web.curves.CurveBundleResource;
import com.opengamma.sesame.web.pricing.SwapPricingResource;
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 java.util.LinkedHashMap;
import java.util.Map;
/**
* Web component to register resources to expose REST endpoints
*/
@BeanDefinition
public class WebComponentFactory extends AbstractComponentFactory {
/** Builds market data that's required by the calculations but not supplied by the user. */
@PropertyDefinition(validate = "notNull")
private MarketDataEnvironmentFactory _marketDataEnvironmentFactory;
@PropertyDefinition(validate = "notNull")
private ViewRunner _viewRunner;
@PropertyDefinition(validate = "notNull")
private String _currencyMatrix;
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
repo.getRestComponents().publishResource(new SwapPricingResource(_marketDataEnvironmentFactory, _viewRunner, _currencyMatrix));
repo.getRestComponents().publishResource(new CurveBundleResource(_marketDataEnvironmentFactory));
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code WebComponentFactory}.
* @return the meta-bean, not null
*/
public static WebComponentFactory.Meta meta() {
return WebComponentFactory.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(WebComponentFactory.Meta.INSTANCE);
}
@Override
public WebComponentFactory.Meta metaBean() {
return WebComponentFactory.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets builds market data that's required by the calculations but not supplied by the user.
* @return the value of the property, not null
*/
public MarketDataEnvironmentFactory getMarketDataEnvironmentFactory() {
return _marketDataEnvironmentFactory;
}
/**
* Sets builds market data that's required by the calculations but not supplied by the user.
* @param marketDataEnvironmentFactory the new value of the property, not null
*/
public void setMarketDataEnvironmentFactory(MarketDataEnvironmentFactory marketDataEnvironmentFactory) {
JodaBeanUtils.notNull(marketDataEnvironmentFactory, "marketDataEnvironmentFactory");
this._marketDataEnvironmentFactory = marketDataEnvironmentFactory;
}
/**
* Gets the the {@code marketDataEnvironmentFactory} property.
* @return the property, not null
*/
public final Property<MarketDataEnvironmentFactory> marketDataEnvironmentFactory() {
return metaBean().marketDataEnvironmentFactory().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the viewRunner.
* @return the value of the property, not null
*/
public ViewRunner getViewRunner() {
return _viewRunner;
}
/**
* Sets the viewRunner.
* @param viewRunner the new value of the property, not null
*/
public void setViewRunner(ViewRunner viewRunner) {
JodaBeanUtils.notNull(viewRunner, "viewRunner");
this._viewRunner = viewRunner;
}
/**
* Gets the the {@code viewRunner} property.
* @return the property, not null
*/
public final Property<ViewRunner> viewRunner() {
return metaBean().viewRunner().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the currencyMatrix.
* @return the value of the property, not null
*/
public String getCurrencyMatrix() {
return _currencyMatrix;
}
/**
* Sets the currencyMatrix.
* @param currencyMatrix the new value of the property, not null
*/
public void setCurrencyMatrix(String currencyMatrix) {
JodaBeanUtils.notNull(currencyMatrix, "currencyMatrix");
this._currencyMatrix = currencyMatrix;
}
/**
* Gets the the {@code currencyMatrix} property.
* @return the property, not null
*/
public final Property<String> currencyMatrix() {
return metaBean().currencyMatrix().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public WebComponentFactory clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
WebComponentFactory other = (WebComponentFactory) obj;
return JodaBeanUtils.equal(getMarketDataEnvironmentFactory(), other.getMarketDataEnvironmentFactory()) &&
JodaBeanUtils.equal(getViewRunner(), other.getViewRunner()) &&
JodaBeanUtils.equal(getCurrencyMatrix(), other.getCurrencyMatrix()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getMarketDataEnvironmentFactory());
hash = hash * 31 + JodaBeanUtils.hashCode(getViewRunner());
hash = hash * 31 + JodaBeanUtils.hashCode(getCurrencyMatrix());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(128);
buf.append("WebComponentFactory{");
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("marketDataEnvironmentFactory").append('=').append(JodaBeanUtils.toString(getMarketDataEnvironmentFactory())).append(',').append(' ');
buf.append("viewRunner").append('=').append(JodaBeanUtils.toString(getViewRunner())).append(',').append(' ');
buf.append("currencyMatrix").append('=').append(JodaBeanUtils.toString(getCurrencyMatrix())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code WebComponentFactory}.
*/
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 marketDataEnvironmentFactory} property.
*/
private final MetaProperty<MarketDataEnvironmentFactory> _marketDataEnvironmentFactory = DirectMetaProperty.ofReadWrite(
this, "marketDataEnvironmentFactory", WebComponentFactory.class, MarketDataEnvironmentFactory.class);
/**
* The meta-property for the {@code viewRunner} property.
*/
private final MetaProperty<ViewRunner> _viewRunner = DirectMetaProperty.ofReadWrite(
this, "viewRunner", WebComponentFactory.class, ViewRunner.class);
/**
* The meta-property for the {@code currencyMatrix} property.
*/
private final MetaProperty<String> _currencyMatrix = DirectMetaProperty.ofReadWrite(
this, "currencyMatrix", WebComponentFactory.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"marketDataEnvironmentFactory",
"viewRunner",
"currencyMatrix");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 964996125: // marketDataEnvironmentFactory
return _marketDataEnvironmentFactory;
case -1889946059: // viewRunner
return _viewRunner;
case -506174670: // currencyMatrix
return _currencyMatrix;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends WebComponentFactory> builder() {
return new DirectBeanBuilder<WebComponentFactory>(new WebComponentFactory());
}
@Override
public Class<? extends WebComponentFactory> beanType() {
return WebComponentFactory.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code marketDataEnvironmentFactory} property.
* @return the meta-property, not null
*/
public final MetaProperty<MarketDataEnvironmentFactory> marketDataEnvironmentFactory() {
return _marketDataEnvironmentFactory;
}
/**
* The meta-property for the {@code viewRunner} property.
* @return the meta-property, not null
*/
public final MetaProperty<ViewRunner> viewRunner() {
return _viewRunner;
}
/**
* The meta-property for the {@code currencyMatrix} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> currencyMatrix() {
return _currencyMatrix;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 964996125: // marketDataEnvironmentFactory
return ((WebComponentFactory) bean).getMarketDataEnvironmentFactory();
case -1889946059: // viewRunner
return ((WebComponentFactory) bean).getViewRunner();
case -506174670: // currencyMatrix
return ((WebComponentFactory) bean).getCurrencyMatrix();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 964996125: // marketDataEnvironmentFactory
((WebComponentFactory) bean).setMarketDataEnvironmentFactory((MarketDataEnvironmentFactory) newValue);
return;
case -1889946059: // viewRunner
((WebComponentFactory) bean).setViewRunner((ViewRunner) newValue);
return;
case -506174670: // currencyMatrix
((WebComponentFactory) bean).setCurrencyMatrix((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((WebComponentFactory) bean)._marketDataEnvironmentFactory, "marketDataEnvironmentFactory");
JodaBeanUtils.notNull(((WebComponentFactory) bean)._viewRunner, "viewRunner");
JodaBeanUtils.notNull(((WebComponentFactory) bean)._currencyMatrix, "currencyMatrix");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}