/**
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.engine.function.config;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
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.DirectBean;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.google.common.collect.Lists;
import com.opengamma.util.ArgumentChecker;
/**
* Container for function configurations
*/
@BeanDefinition
public class FunctionConfigurationBundle extends DirectBean implements Serializable {
private static final long serialVersionUID = 1L;
@PropertyDefinition(set = "setClearAddAll")
private List<FunctionConfiguration> _functions = Lists.newArrayList();
/**
* Creates an instance.
*
* @param functions the list of function configurations, not-null.
*/
public FunctionConfigurationBundle(Collection<FunctionConfiguration> functions) {
ArgumentChecker.notNull(functions, "functions");
_functions.addAll(functions);
}
/**
* Creates an empty bundle.
*/
public FunctionConfigurationBundle() {
}
public void addFunctions(FunctionConfiguration functionConfiguration) {
ArgumentChecker.notNull(functionConfiguration, "function configuration");
_functions.add(functionConfiguration);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code FunctionConfigurationBundle}.
* @return the meta-bean, not null
*/
public static FunctionConfigurationBundle.Meta meta() {
return FunctionConfigurationBundle.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(FunctionConfigurationBundle.Meta.INSTANCE);
}
@Override
public FunctionConfigurationBundle.Meta metaBean() {
return FunctionConfigurationBundle.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the functions.
* @return the value of the property
*/
public List<FunctionConfiguration> getFunctions() {
return _functions;
}
/**
* Sets the functions.
* @param functions the new value of the property
*/
public void setFunctions(List<FunctionConfiguration> functions) {
this._functions.clear();
this._functions.addAll(functions);
}
/**
* Gets the the {@code functions} property.
* @return the property, not null
*/
public final Property<List<FunctionConfiguration>> functions() {
return metaBean().functions().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public FunctionConfigurationBundle clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
FunctionConfigurationBundle other = (FunctionConfigurationBundle) obj;
return JodaBeanUtils.equal(getFunctions(), other.getFunctions());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getFunctions());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(64);
buf.append("FunctionConfigurationBundle{");
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("functions").append('=').append(JodaBeanUtils.toString(getFunctions())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code FunctionConfigurationBundle}.
*/
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 functions} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<List<FunctionConfiguration>> _functions = DirectMetaProperty.ofReadWrite(
this, "functions", FunctionConfigurationBundle.class, (Class) List.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"functions");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -140572773: // functions
return _functions;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends FunctionConfigurationBundle> builder() {
return new DirectBeanBuilder<FunctionConfigurationBundle>(new FunctionConfigurationBundle());
}
@Override
public Class<? extends FunctionConfigurationBundle> beanType() {
return FunctionConfigurationBundle.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code functions} property.
* @return the meta-property, not null
*/
public final MetaProperty<List<FunctionConfiguration>> functions() {
return _functions;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -140572773: // functions
return ((FunctionConfigurationBundle) bean).getFunctions();
}
return super.propertyGet(bean, propertyName, quiet);
}
@SuppressWarnings("unchecked")
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -140572773: // functions
((FunctionConfigurationBundle) bean).setFunctions((List<FunctionConfiguration>) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}