/**
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.livedata.cogda.msg;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.fudgemsg.FudgeField;
import org.fudgemsg.FudgeMsg;
import org.fudgemsg.MutableFudgeMsg;
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.opengamma.util.fudgemsg.OpenGammaFudgeContext;
/**
*
*/
@BeanDefinition
public class ConnectionResponseMessage extends DirectBean {
/**
* The classifier under which to publish.
*/
@PropertyDefinition(validate = "notNull")
private ConnectionResult _result;
/**
* All available servers for the client for purposes of reconnection.
*/
@PropertyDefinition(validate = "notNull")
private List<String> _availableServers = new LinkedList<String>();
/**
* Capabilities supported by this server.
*/
@PropertyDefinition(validate = "notNull")
private MutableFudgeMsg _capabilities = OpenGammaFudgeContext.getInstance().newMessage();
public void applyCapabilities(FudgeMsg capabilities) {
for (FudgeField field : capabilities.getAllFields()) {
getCapabilities().add(field);
}
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code ConnectionResponseMessage}.
* @return the meta-bean, not null
*/
public static ConnectionResponseMessage.Meta meta() {
return ConnectionResponseMessage.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(ConnectionResponseMessage.Meta.INSTANCE);
}
@Override
public ConnectionResponseMessage.Meta metaBean() {
return ConnectionResponseMessage.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the classifier under which to publish.
* @return the value of the property, not null
*/
public ConnectionResult getResult() {
return _result;
}
/**
* Sets the classifier under which to publish.
* @param result the new value of the property, not null
*/
public void setResult(ConnectionResult result) {
JodaBeanUtils.notNull(result, "result");
this._result = result;
}
/**
* Gets the the {@code result} property.
* @return the property, not null
*/
public final Property<ConnectionResult> result() {
return metaBean().result().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets all available servers for the client for purposes of reconnection.
* @return the value of the property, not null
*/
public List<String> getAvailableServers() {
return _availableServers;
}
/**
* Sets all available servers for the client for purposes of reconnection.
* @param availableServers the new value of the property, not null
*/
public void setAvailableServers(List<String> availableServers) {
JodaBeanUtils.notNull(availableServers, "availableServers");
this._availableServers = availableServers;
}
/**
* Gets the the {@code availableServers} property.
* @return the property, not null
*/
public final Property<List<String>> availableServers() {
return metaBean().availableServers().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets capabilities supported by this server.
* @return the value of the property, not null
*/
public MutableFudgeMsg getCapabilities() {
return _capabilities;
}
/**
* Sets capabilities supported by this server.
* @param capabilities the new value of the property, not null
*/
public void setCapabilities(MutableFudgeMsg capabilities) {
JodaBeanUtils.notNull(capabilities, "capabilities");
this._capabilities = capabilities;
}
/**
* Gets the the {@code capabilities} property.
* @return the property, not null
*/
public final Property<MutableFudgeMsg> capabilities() {
return metaBean().capabilities().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public ConnectionResponseMessage clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
ConnectionResponseMessage other = (ConnectionResponseMessage) obj;
return JodaBeanUtils.equal(getResult(), other.getResult()) &&
JodaBeanUtils.equal(getAvailableServers(), other.getAvailableServers()) &&
JodaBeanUtils.equal(getCapabilities(), other.getCapabilities());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getResult());
hash = hash * 31 + JodaBeanUtils.hashCode(getAvailableServers());
hash = hash * 31 + JodaBeanUtils.hashCode(getCapabilities());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(128);
buf.append("ConnectionResponseMessage{");
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("result").append('=').append(JodaBeanUtils.toString(getResult())).append(',').append(' ');
buf.append("availableServers").append('=').append(JodaBeanUtils.toString(getAvailableServers())).append(',').append(' ');
buf.append("capabilities").append('=').append(JodaBeanUtils.toString(getCapabilities())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code ConnectionResponseMessage}.
*/
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 result} property.
*/
private final MetaProperty<ConnectionResult> _result = DirectMetaProperty.ofReadWrite(
this, "result", ConnectionResponseMessage.class, ConnectionResult.class);
/**
* The meta-property for the {@code availableServers} property.
*/
@SuppressWarnings({"unchecked", "rawtypes" })
private final MetaProperty<List<String>> _availableServers = DirectMetaProperty.ofReadWrite(
this, "availableServers", ConnectionResponseMessage.class, (Class) List.class);
/**
* The meta-property for the {@code capabilities} property.
*/
private final MetaProperty<MutableFudgeMsg> _capabilities = DirectMetaProperty.ofReadWrite(
this, "capabilities", ConnectionResponseMessage.class, MutableFudgeMsg.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"result",
"availableServers",
"capabilities");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -934426595: // result
return _result;
case -602422649: // availableServers
return _availableServers;
case -1487597642: // capabilities
return _capabilities;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends ConnectionResponseMessage> builder() {
return new DirectBeanBuilder<ConnectionResponseMessage>(new ConnectionResponseMessage());
}
@Override
public Class<? extends ConnectionResponseMessage> beanType() {
return ConnectionResponseMessage.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code result} property.
* @return the meta-property, not null
*/
public final MetaProperty<ConnectionResult> result() {
return _result;
}
/**
* The meta-property for the {@code availableServers} property.
* @return the meta-property, not null
*/
public final MetaProperty<List<String>> availableServers() {
return _availableServers;
}
/**
* The meta-property for the {@code capabilities} property.
* @return the meta-property, not null
*/
public final MetaProperty<MutableFudgeMsg> capabilities() {
return _capabilities;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -934426595: // result
return ((ConnectionResponseMessage) bean).getResult();
case -602422649: // availableServers
return ((ConnectionResponseMessage) bean).getAvailableServers();
case -1487597642: // capabilities
return ((ConnectionResponseMessage) bean).getCapabilities();
}
return super.propertyGet(bean, propertyName, quiet);
}
@SuppressWarnings("unchecked")
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -934426595: // result
((ConnectionResponseMessage) bean).setResult((ConnectionResult) newValue);
return;
case -602422649: // availableServers
((ConnectionResponseMessage) bean).setAvailableServers((List<String>) newValue);
return;
case -1487597642: // capabilities
((ConnectionResponseMessage) bean).setCapabilities((MutableFudgeMsg) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((ConnectionResponseMessage) bean)._result, "result");
JodaBeanUtils.notNull(((ConnectionResponseMessage) bean)._availableServers, "availableServers");
JodaBeanUtils.notNull(((ConnectionResponseMessage) bean)._capabilities, "capabilities");
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}