/** * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.sesame.config; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import org.joda.beans.Bean; import org.joda.beans.BeanDefinition; import org.joda.beans.ImmutableBean; import org.joda.beans.ImmutableConstructor; 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.DirectFieldsBeanBuilder; import org.joda.beans.impl.direct.DirectMetaBean; import org.joda.beans.impl.direct.DirectMetaProperty; import org.joda.beans.impl.direct.DirectMetaPropertyMap; import com.opengamma.sesame.OutputName; import com.opengamma.util.ArgumentChecker; /** * Configuration object that defines an output value in a view. * <p> * Contains the output name and the configuration. */ @BeanDefinition public final class ViewOutput implements ImmutableBean { /** * The output name, null if inherited from the column. */ @PropertyDefinition private final OutputName _outputName; /** * The configuration. */ @PropertyDefinition(validate = "notNull") private final FunctionModelConfig _functionModelConfig; /** * Creates an instance with empty configuration. * * @param outputName the output name, null to inherit from the column */ public ViewOutput(OutputName outputName) { this(outputName, FunctionModelConfig.EMPTY); } /** * Creates an instance. * * @param functionModelConfig the configuration, not null */ public ViewOutput(FunctionModelConfig functionModelConfig) { this(null, functionModelConfig); } /** * Creates an instance. * * @param outputName the output name, null to inherit from the column * @param functionModelConfig the configuration, not null */ @ImmutableConstructor public ViewOutput(OutputName outputName, FunctionModelConfig functionModelConfig) { _outputName = outputName; _functionModelConfig = ArgumentChecker.notNull(functionModelConfig, "functionConfig"); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code ViewOutput}. * @return the meta-bean, not null */ public static ViewOutput.Meta meta() { return ViewOutput.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(ViewOutput.Meta.INSTANCE); } /** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static ViewOutput.Builder builder() { return new ViewOutput.Builder(); } @Override public ViewOutput.Meta metaBean() { return ViewOutput.Meta.INSTANCE; } @Override public <R> Property<R> property(String propertyName) { return metaBean().<R>metaProperty(propertyName).createProperty(this); } @Override public Set<String> propertyNames() { return metaBean().metaPropertyMap().keySet(); } //----------------------------------------------------------------------- /** * Gets the output name, null if inherited from the column. * @return the value of the property */ public OutputName getOutputName() { return _outputName; } //----------------------------------------------------------------------- /** * Gets the configuration. * @return the value of the property, not null */ public FunctionModelConfig getFunctionModelConfig() { return _functionModelConfig; } //----------------------------------------------------------------------- /** * Returns a builder that allows this bean to be mutated. * @return the mutable builder, not null */ public Builder toBuilder() { return new Builder(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { ViewOutput other = (ViewOutput) obj; return JodaBeanUtils.equal(getOutputName(), other.getOutputName()) && JodaBeanUtils.equal(getFunctionModelConfig(), other.getFunctionModelConfig()); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(getOutputName()); hash = hash * 31 + JodaBeanUtils.hashCode(getFunctionModelConfig()); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(96); buf.append("ViewOutput{"); buf.append("outputName").append('=').append(getOutputName()).append(',').append(' '); buf.append("functionModelConfig").append('=').append(JodaBeanUtils.toString(getFunctionModelConfig())); buf.append('}'); return buf.toString(); } //----------------------------------------------------------------------- /** * The meta-bean for {@code ViewOutput}. */ public static final class Meta extends DirectMetaBean { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code outputName} property. */ private final MetaProperty<OutputName> _outputName = DirectMetaProperty.ofImmutable( this, "outputName", ViewOutput.class, OutputName.class); /** * The meta-property for the {@code functionModelConfig} property. */ private final MetaProperty<FunctionModelConfig> _functionModelConfig = DirectMetaProperty.ofImmutable( this, "functionModelConfig", ViewOutput.class, FunctionModelConfig.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, null, "outputName", "functionModelConfig"); /** * Restricted constructor. */ private Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -1274044628: // outputName return _outputName; case 645366995: // functionModelConfig return _functionModelConfig; } return super.metaPropertyGet(propertyName); } @Override public ViewOutput.Builder builder() { return new ViewOutput.Builder(); } @Override public Class<? extends ViewOutput> beanType() { return ViewOutput.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code outputName} property. * @return the meta-property, not null */ public MetaProperty<OutputName> outputName() { return _outputName; } /** * The meta-property for the {@code functionModelConfig} property. * @return the meta-property, not null */ public MetaProperty<FunctionModelConfig> functionModelConfig() { return _functionModelConfig; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -1274044628: // outputName return ((ViewOutput) bean).getOutputName(); case 645366995: // functionModelConfig return ((ViewOutput) bean).getFunctionModelConfig(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { metaProperty(propertyName); if (quiet) { return; } throw new UnsupportedOperationException("Property cannot be written: " + propertyName); } } //----------------------------------------------------------------------- /** * The bean-builder for {@code ViewOutput}. */ public static final class Builder extends DirectFieldsBeanBuilder<ViewOutput> { private OutputName _outputName; private FunctionModelConfig _functionModelConfig; /** * Restricted constructor. */ private Builder() { } /** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ViewOutput beanToCopy) { this._outputName = beanToCopy.getOutputName(); this._functionModelConfig = beanToCopy.getFunctionModelConfig(); } //----------------------------------------------------------------------- @Override public Object get(String propertyName) { switch (propertyName.hashCode()) { case -1274044628: // outputName return _outputName; case 645366995: // functionModelConfig return _functionModelConfig; default: throw new NoSuchElementException("Unknown property: " + propertyName); } } @Override public Builder set(String propertyName, Object newValue) { switch (propertyName.hashCode()) { case -1274044628: // outputName this._outputName = (OutputName) newValue; break; case 645366995: // functionModelConfig this._functionModelConfig = (FunctionModelConfig) newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return this; } @Override public Builder set(MetaProperty<?> property, Object value) { super.set(property, value); return this; } @Override public Builder setString(String propertyName, String value) { setString(meta().metaProperty(propertyName), value); return this; } @Override public Builder setString(MetaProperty<?> property, String value) { super.setString(property, value); return this; } @Override public Builder setAll(Map<String, ? extends Object> propertyValueMap) { super.setAll(propertyValueMap); return this; } @Override public ViewOutput build() { return new ViewOutput( _outputName, _functionModelConfig); } //----------------------------------------------------------------------- /** * Sets the {@code outputName} property in the builder. * @param outputName the new value * @return this, for chaining, not null */ public Builder outputName(OutputName outputName) { this._outputName = outputName; return this; } /** * Sets the {@code functionModelConfig} property in the builder. * @param functionModelConfig the new value, not null * @return this, for chaining, not null */ public Builder functionModelConfig(FunctionModelConfig functionModelConfig) { JodaBeanUtils.notNull(functionModelConfig, "functionModelConfig"); this._functionModelConfig = functionModelConfig; return this; } //----------------------------------------------------------------------- @Override public String toString() { StringBuilder buf = new StringBuilder(96); buf.append("ViewOutput.Builder{"); buf.append("outputName").append('=').append(JodaBeanUtils.toString(_outputName)).append(',').append(' '); buf.append("functionModelConfig").append('=').append(JodaBeanUtils.toString(_functionModelConfig)); buf.append('}'); return buf.toString(); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }