/** * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.web.exchange; import java.util.Map; import javax.ws.rs.core.UriInfo; 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 com.opengamma.id.UniqueId; import com.opengamma.master.exchange.ExchangeDocument; import com.opengamma.master.exchange.ExchangeMaster; import com.opengamma.web.WebPerRequestData; /** * Data class for web-based exchanges. */ @BeanDefinition public class WebExchangeData extends WebPerRequestData { /** * The exchange master. */ @PropertyDefinition private ExchangeMaster _exchangeMaster; /** * The exchange id from the input URI. */ @PropertyDefinition private String _uriExchangeId; /** * The version id from the URI. */ @PropertyDefinition private String _uriVersionId; /** * The exchange. */ @PropertyDefinition private ExchangeDocument _exchange; /** * The versioned exchange. */ @PropertyDefinition private ExchangeDocument _versioned; /** * Creates an instance. */ public WebExchangeData() { } /** * Creates an instance. * @param uriInfo the URI information */ public WebExchangeData(final UriInfo uriInfo) { setUriInfo(uriInfo); } //------------------------------------------------------------------------- /** * Gets the best available exchange id. * @param overrideId the override id, null derives the result from the data * @return the id, may be null */ public String getBestExchangeUriId(final UniqueId overrideId) { if (overrideId != null) { return overrideId.toLatest().toString(); } return getExchange() != null ? getExchange().getUniqueId().toLatest().toString() : getUriExchangeId(); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code WebExchangeData}. * @return the meta-bean, not null */ public static WebExchangeData.Meta meta() { return WebExchangeData.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(WebExchangeData.Meta.INSTANCE); } @Override public WebExchangeData.Meta metaBean() { return WebExchangeData.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the exchange master. * @return the value of the property */ public ExchangeMaster getExchangeMaster() { return _exchangeMaster; } /** * Sets the exchange master. * @param exchangeMaster the new value of the property */ public void setExchangeMaster(ExchangeMaster exchangeMaster) { this._exchangeMaster = exchangeMaster; } /** * Gets the the {@code exchangeMaster} property. * @return the property, not null */ public final Property<ExchangeMaster> exchangeMaster() { return metaBean().exchangeMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the exchange id from the input URI. * @return the value of the property */ public String getUriExchangeId() { return _uriExchangeId; } /** * Sets the exchange id from the input URI. * @param uriExchangeId the new value of the property */ public void setUriExchangeId(String uriExchangeId) { this._uriExchangeId = uriExchangeId; } /** * Gets the the {@code uriExchangeId} property. * @return the property, not null */ public final Property<String> uriExchangeId() { return metaBean().uriExchangeId().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the version id from the URI. * @return the value of the property */ public String getUriVersionId() { return _uriVersionId; } /** * Sets the version id from the URI. * @param uriVersionId the new value of the property */ public void setUriVersionId(String uriVersionId) { this._uriVersionId = uriVersionId; } /** * Gets the the {@code uriVersionId} property. * @return the property, not null */ public final Property<String> uriVersionId() { return metaBean().uriVersionId().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the exchange. * @return the value of the property */ public ExchangeDocument getExchange() { return _exchange; } /** * Sets the exchange. * @param exchange the new value of the property */ public void setExchange(ExchangeDocument exchange) { this._exchange = exchange; } /** * Gets the the {@code exchange} property. * @return the property, not null */ public final Property<ExchangeDocument> exchange() { return metaBean().exchange().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the versioned exchange. * @return the value of the property */ public ExchangeDocument getVersioned() { return _versioned; } /** * Sets the versioned exchange. * @param versioned the new value of the property */ public void setVersioned(ExchangeDocument versioned) { this._versioned = versioned; } /** * Gets the the {@code versioned} property. * @return the property, not null */ public final Property<ExchangeDocument> versioned() { return metaBean().versioned().createProperty(this); } //----------------------------------------------------------------------- @Override public WebExchangeData clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { WebExchangeData other = (WebExchangeData) obj; return JodaBeanUtils.equal(getExchangeMaster(), other.getExchangeMaster()) && JodaBeanUtils.equal(getUriExchangeId(), other.getUriExchangeId()) && JodaBeanUtils.equal(getUriVersionId(), other.getUriVersionId()) && JodaBeanUtils.equal(getExchange(), other.getExchange()) && JodaBeanUtils.equal(getVersioned(), other.getVersioned()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getExchangeMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getUriExchangeId()); hash = hash * 31 + JodaBeanUtils.hashCode(getUriVersionId()); hash = hash * 31 + JodaBeanUtils.hashCode(getExchange()); hash = hash * 31 + JodaBeanUtils.hashCode(getVersioned()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(192); buf.append("WebExchangeData{"); 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("exchangeMaster").append('=').append(JodaBeanUtils.toString(getExchangeMaster())).append(',').append(' '); buf.append("uriExchangeId").append('=').append(JodaBeanUtils.toString(getUriExchangeId())).append(',').append(' '); buf.append("uriVersionId").append('=').append(JodaBeanUtils.toString(getUriVersionId())).append(',').append(' '); buf.append("exchange").append('=').append(JodaBeanUtils.toString(getExchange())).append(',').append(' '); buf.append("versioned").append('=').append(JodaBeanUtils.toString(getVersioned())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code WebExchangeData}. */ public static class Meta extends WebPerRequestData.Meta { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code exchangeMaster} property. */ private final MetaProperty<ExchangeMaster> _exchangeMaster = DirectMetaProperty.ofReadWrite( this, "exchangeMaster", WebExchangeData.class, ExchangeMaster.class); /** * The meta-property for the {@code uriExchangeId} property. */ private final MetaProperty<String> _uriExchangeId = DirectMetaProperty.ofReadWrite( this, "uriExchangeId", WebExchangeData.class, String.class); /** * The meta-property for the {@code uriVersionId} property. */ private final MetaProperty<String> _uriVersionId = DirectMetaProperty.ofReadWrite( this, "uriVersionId", WebExchangeData.class, String.class); /** * The meta-property for the {@code exchange} property. */ private final MetaProperty<ExchangeDocument> _exchange = DirectMetaProperty.ofReadWrite( this, "exchange", WebExchangeData.class, ExchangeDocument.class); /** * The meta-property for the {@code versioned} property. */ private final MetaProperty<ExchangeDocument> _versioned = DirectMetaProperty.ofReadWrite( this, "versioned", WebExchangeData.class, ExchangeDocument.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "exchangeMaster", "uriExchangeId", "uriVersionId", "exchange", "versioned"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -652001691: // exchangeMaster return _exchangeMaster; case 772498730: // uriExchangeId return _uriExchangeId; case 666567687: // uriVersionId return _uriVersionId; case 1989774883: // exchange return _exchange; case -1407102089: // versioned return _versioned; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends WebExchangeData> builder() { return new DirectBeanBuilder<WebExchangeData>(new WebExchangeData()); } @Override public Class<? extends WebExchangeData> beanType() { return WebExchangeData.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code exchangeMaster} property. * @return the meta-property, not null */ public final MetaProperty<ExchangeMaster> exchangeMaster() { return _exchangeMaster; } /** * The meta-property for the {@code uriExchangeId} property. * @return the meta-property, not null */ public final MetaProperty<String> uriExchangeId() { return _uriExchangeId; } /** * The meta-property for the {@code uriVersionId} property. * @return the meta-property, not null */ public final MetaProperty<String> uriVersionId() { return _uriVersionId; } /** * The meta-property for the {@code exchange} property. * @return the meta-property, not null */ public final MetaProperty<ExchangeDocument> exchange() { return _exchange; } /** * The meta-property for the {@code versioned} property. * @return the meta-property, not null */ public final MetaProperty<ExchangeDocument> versioned() { return _versioned; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -652001691: // exchangeMaster return ((WebExchangeData) bean).getExchangeMaster(); case 772498730: // uriExchangeId return ((WebExchangeData) bean).getUriExchangeId(); case 666567687: // uriVersionId return ((WebExchangeData) bean).getUriVersionId(); case 1989774883: // exchange return ((WebExchangeData) bean).getExchange(); case -1407102089: // versioned return ((WebExchangeData) bean).getVersioned(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -652001691: // exchangeMaster ((WebExchangeData) bean).setExchangeMaster((ExchangeMaster) newValue); return; case 772498730: // uriExchangeId ((WebExchangeData) bean).setUriExchangeId((String) newValue); return; case 666567687: // uriVersionId ((WebExchangeData) bean).setUriVersionId((String) newValue); return; case 1989774883: // exchange ((WebExchangeData) bean).setExchange((ExchangeDocument) newValue); return; case -1407102089: // versioned ((WebExchangeData) bean).setVersioned((ExchangeDocument) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }