/** * 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.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; /** * An initial connection request message sent by a client to a COGDA server. */ @BeanDefinition public class ConnectionRequestMessage extends DirectBean { /** * The classifier under which to publish. */ @PropertyDefinition(validate = "notNull") private String _userName; /** * The user's password. This should not be hashed or otherwise * pre-modified. It may be null, which may be permitted by the particular * server. */ @PropertyDefinition private String _password; /** * 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 ConnectionRequestMessage}. * @return the meta-bean, not null */ public static ConnectionRequestMessage.Meta meta() { return ConnectionRequestMessage.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(ConnectionRequestMessage.Meta.INSTANCE); } @Override public ConnectionRequestMessage.Meta metaBean() { return ConnectionRequestMessage.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the classifier under which to publish. * @return the value of the property, not null */ public String getUserName() { return _userName; } /** * Sets the classifier under which to publish. * @param userName the new value of the property, not null */ public void setUserName(String userName) { JodaBeanUtils.notNull(userName, "userName"); this._userName = userName; } /** * Gets the the {@code userName} property. * @return the property, not null */ public final Property<String> userName() { return metaBean().userName().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the user's password. This should not be hashed or otherwise * pre-modified. It may be null, which may be permitted by the particular * server. * @return the value of the property */ public String getPassword() { return _password; } /** * Sets the user's password. This should not be hashed or otherwise * pre-modified. It may be null, which may be permitted by the particular * server. * @param password the new value of the property */ public void setPassword(String password) { this._password = password; } /** * Gets the the {@code password} property. * pre-modified. It may be null, which may be permitted by the particular * server. * @return the property, not null */ public final Property<String> password() { return metaBean().password().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 ConnectionRequestMessage clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { ConnectionRequestMessage other = (ConnectionRequestMessage) obj; return JodaBeanUtils.equal(getUserName(), other.getUserName()) && JodaBeanUtils.equal(getPassword(), other.getPassword()) && JodaBeanUtils.equal(getCapabilities(), other.getCapabilities()); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(getUserName()); hash = hash * 31 + JodaBeanUtils.hashCode(getPassword()); hash = hash * 31 + JodaBeanUtils.hashCode(getCapabilities()); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(128); buf.append("ConnectionRequestMessage{"); 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("userName").append('=').append(JodaBeanUtils.toString(getUserName())).append(',').append(' '); buf.append("password").append('=').append(JodaBeanUtils.toString(getPassword())).append(',').append(' '); buf.append("capabilities").append('=').append(JodaBeanUtils.toString(getCapabilities())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code ConnectionRequestMessage}. */ 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 userName} property. */ private final MetaProperty<String> _userName = DirectMetaProperty.ofReadWrite( this, "userName", ConnectionRequestMessage.class, String.class); /** * The meta-property for the {@code password} property. */ private final MetaProperty<String> _password = DirectMetaProperty.ofReadWrite( this, "password", ConnectionRequestMessage.class, String.class); /** * The meta-property for the {@code capabilities} property. */ private final MetaProperty<MutableFudgeMsg> _capabilities = DirectMetaProperty.ofReadWrite( this, "capabilities", ConnectionRequestMessage.class, MutableFudgeMsg.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, null, "userName", "password", "capabilities"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -266666762: // userName return _userName; case 1216985755: // password return _password; case -1487597642: // capabilities return _capabilities; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends ConnectionRequestMessage> builder() { return new DirectBeanBuilder<ConnectionRequestMessage>(new ConnectionRequestMessage()); } @Override public Class<? extends ConnectionRequestMessage> beanType() { return ConnectionRequestMessage.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code userName} property. * @return the meta-property, not null */ public final MetaProperty<String> userName() { return _userName; } /** * The meta-property for the {@code password} property. * @return the meta-property, not null */ public final MetaProperty<String> password() { return _password; } /** * 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 -266666762: // userName return ((ConnectionRequestMessage) bean).getUserName(); case 1216985755: // password return ((ConnectionRequestMessage) bean).getPassword(); case -1487597642: // capabilities return ((ConnectionRequestMessage) bean).getCapabilities(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -266666762: // userName ((ConnectionRequestMessage) bean).setUserName((String) newValue); return; case 1216985755: // password ((ConnectionRequestMessage) bean).setPassword((String) newValue); return; case -1487597642: // capabilities ((ConnectionRequestMessage) bean).setCapabilities((MutableFudgeMsg) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((ConnectionRequestMessage) bean)._userName, "userName"); JodaBeanUtils.notNull(((ConnectionRequestMessage) bean)._capabilities, "capabilities"); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }