/** * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.web.legalentity; 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.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.opengamma.id.UniqueId; import com.opengamma.master.legalentity.LegalEntityDocument; import com.opengamma.master.legalentity.LegalEntityMaster; import com.opengamma.master.legalentity.ManageableLegalEntity; import com.opengamma.master.security.SecurityMaster; import com.opengamma.web.WebPerRequestData; /** Data class for web-based legalEntity management. */ @BeanDefinition public class WebLegalEntityData extends WebPerRequestData { /** * The legalEntity master. */ @PropertyDefinition private LegalEntityMaster _legalEntityMaster; /** * The security master. */ @PropertyDefinition private SecurityMaster _securityMaster; /** The type of data being stored. */ @PropertyDefinition private Class<?> _type; /** The legalEntity id from the input URI. */ @PropertyDefinition private String _uriLegalEntityId; /** The version id from the URI. */ @PropertyDefinition private String _uriVersionId; /** The legalEntity. */ @PropertyDefinition private LegalEntityDocument _legalEntity; /** The versioned legalEntity. */ @PropertyDefinition private LegalEntityDocument _versioned; /** The valid map of types. */ @PropertyDefinition(set = "setClearPutAll") private final BiMap<String, Class<? extends ManageableLegalEntity>> _typeMap = HashBiMap.create(); /** Creates an instance. */ public WebLegalEntityData() { } /** * Creates an instance. * * @param uriInfo the URI information */ public WebLegalEntityData(final UriInfo uriInfo) { setUriInfo(uriInfo); } //------------------------------------------------------------------------- /** * Gets the best available legalEntity id. * * @param overrideId the override id, null derives the result from the data * @return the id, may be null */ public String getBestLegalEntityUriId(final UniqueId overrideId) { if (overrideId != null) { return overrideId.toLatest().toString(); } return getLegalEntity() != null ? getLegalEntity().getUniqueId().toLatest().toString() : getUriLegalEntityId(); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code WebLegalEntityData}. * @return the meta-bean, not null */ public static WebLegalEntityData.Meta meta() { return WebLegalEntityData.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(WebLegalEntityData.Meta.INSTANCE); } @Override public WebLegalEntityData.Meta metaBean() { return WebLegalEntityData.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the legalEntity master. * @return the value of the property */ public LegalEntityMaster getLegalEntityMaster() { return _legalEntityMaster; } /** * Sets the legalEntity master. * @param legalEntityMaster the new value of the property */ public void setLegalEntityMaster(LegalEntityMaster legalEntityMaster) { this._legalEntityMaster = legalEntityMaster; } /** * Gets the the {@code legalEntityMaster} property. * @return the property, not null */ public final Property<LegalEntityMaster> legalEntityMaster() { return metaBean().legalEntityMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the security master. * @return the value of the property */ public SecurityMaster getSecurityMaster() { return _securityMaster; } /** * Sets the security master. * @param securityMaster the new value of the property */ public void setSecurityMaster(SecurityMaster securityMaster) { this._securityMaster = securityMaster; } /** * Gets the the {@code securityMaster} property. * @return the property, not null */ public final Property<SecurityMaster> securityMaster() { return metaBean().securityMaster().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the type of data being stored. * @return the value of the property */ public Class<?> getType() { return _type; } /** * Sets the type of data being stored. * @param type the new value of the property */ public void setType(Class<?> type) { this._type = type; } /** * Gets the the {@code type} property. * @return the property, not null */ public final Property<Class<?>> type() { return metaBean().type().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the legalEntity id from the input URI. * @return the value of the property */ public String getUriLegalEntityId() { return _uriLegalEntityId; } /** * Sets the legalEntity id from the input URI. * @param uriLegalEntityId the new value of the property */ public void setUriLegalEntityId(String uriLegalEntityId) { this._uriLegalEntityId = uriLegalEntityId; } /** * Gets the the {@code uriLegalEntityId} property. * @return the property, not null */ public final Property<String> uriLegalEntityId() { return metaBean().uriLegalEntityId().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 legalEntity. * @return the value of the property */ public LegalEntityDocument getLegalEntity() { return _legalEntity; } /** * Sets the legalEntity. * @param legalEntity the new value of the property */ public void setLegalEntity(LegalEntityDocument legalEntity) { this._legalEntity = legalEntity; } /** * Gets the the {@code legalEntity} property. * @return the property, not null */ public final Property<LegalEntityDocument> legalEntity() { return metaBean().legalEntity().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the versioned legalEntity. * @return the value of the property */ public LegalEntityDocument getVersioned() { return _versioned; } /** * Sets the versioned legalEntity. * @param versioned the new value of the property */ public void setVersioned(LegalEntityDocument versioned) { this._versioned = versioned; } /** * Gets the the {@code versioned} property. * @return the property, not null */ public final Property<LegalEntityDocument> versioned() { return metaBean().versioned().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the valid map of types. * @return the value of the property, not null */ public BiMap<String, Class<? extends ManageableLegalEntity>> getTypeMap() { return _typeMap; } /** * Sets the valid map of types. * @param typeMap the new value of the property, not null */ public void setTypeMap(BiMap<String, Class<? extends ManageableLegalEntity>> typeMap) { JodaBeanUtils.notNull(typeMap, "typeMap"); this._typeMap.clear(); this._typeMap.putAll(typeMap); } /** * Gets the the {@code typeMap} property. * @return the property, not null */ public final Property<BiMap<String, Class<? extends ManageableLegalEntity>>> typeMap() { return metaBean().typeMap().createProperty(this); } //----------------------------------------------------------------------- @Override public WebLegalEntityData clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { WebLegalEntityData other = (WebLegalEntityData) obj; return JodaBeanUtils.equal(getLegalEntityMaster(), other.getLegalEntityMaster()) && JodaBeanUtils.equal(getSecurityMaster(), other.getSecurityMaster()) && JodaBeanUtils.equal(getType(), other.getType()) && JodaBeanUtils.equal(getUriLegalEntityId(), other.getUriLegalEntityId()) && JodaBeanUtils.equal(getUriVersionId(), other.getUriVersionId()) && JodaBeanUtils.equal(getLegalEntity(), other.getLegalEntity()) && JodaBeanUtils.equal(getVersioned(), other.getVersioned()) && JodaBeanUtils.equal(getTypeMap(), other.getTypeMap()) && super.equals(obj); } return false; } @Override public int hashCode() { int hash = 7; hash = hash * 31 + JodaBeanUtils.hashCode(getLegalEntityMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getSecurityMaster()); hash = hash * 31 + JodaBeanUtils.hashCode(getType()); hash = hash * 31 + JodaBeanUtils.hashCode(getUriLegalEntityId()); hash = hash * 31 + JodaBeanUtils.hashCode(getUriVersionId()); hash = hash * 31 + JodaBeanUtils.hashCode(getLegalEntity()); hash = hash * 31 + JodaBeanUtils.hashCode(getVersioned()); hash = hash * 31 + JodaBeanUtils.hashCode(getTypeMap()); return hash ^ super.hashCode(); } @Override public String toString() { StringBuilder buf = new StringBuilder(288); buf.append("WebLegalEntityData{"); 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("legalEntityMaster").append('=').append(JodaBeanUtils.toString(getLegalEntityMaster())).append(',').append(' '); buf.append("securityMaster").append('=').append(JodaBeanUtils.toString(getSecurityMaster())).append(',').append(' '); buf.append("type").append('=').append(JodaBeanUtils.toString(getType())).append(',').append(' '); buf.append("uriLegalEntityId").append('=').append(JodaBeanUtils.toString(getUriLegalEntityId())).append(',').append(' '); buf.append("uriVersionId").append('=').append(JodaBeanUtils.toString(getUriVersionId())).append(',').append(' '); buf.append("legalEntity").append('=').append(JodaBeanUtils.toString(getLegalEntity())).append(',').append(' '); buf.append("versioned").append('=').append(JodaBeanUtils.toString(getVersioned())).append(',').append(' '); buf.append("typeMap").append('=').append(JodaBeanUtils.toString(getTypeMap())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code WebLegalEntityData}. */ 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 legalEntityMaster} property. */ private final MetaProperty<LegalEntityMaster> _legalEntityMaster = DirectMetaProperty.ofReadWrite( this, "legalEntityMaster", WebLegalEntityData.class, LegalEntityMaster.class); /** * The meta-property for the {@code securityMaster} property. */ private final MetaProperty<SecurityMaster> _securityMaster = DirectMetaProperty.ofReadWrite( this, "securityMaster", WebLegalEntityData.class, SecurityMaster.class); /** * The meta-property for the {@code type} property. */ @SuppressWarnings({"unchecked", "rawtypes" }) private final MetaProperty<Class<?>> _type = DirectMetaProperty.ofReadWrite( this, "type", WebLegalEntityData.class, (Class) Class.class); /** * The meta-property for the {@code uriLegalEntityId} property. */ private final MetaProperty<String> _uriLegalEntityId = DirectMetaProperty.ofReadWrite( this, "uriLegalEntityId", WebLegalEntityData.class, String.class); /** * The meta-property for the {@code uriVersionId} property. */ private final MetaProperty<String> _uriVersionId = DirectMetaProperty.ofReadWrite( this, "uriVersionId", WebLegalEntityData.class, String.class); /** * The meta-property for the {@code legalEntity} property. */ private final MetaProperty<LegalEntityDocument> _legalEntity = DirectMetaProperty.ofReadWrite( this, "legalEntity", WebLegalEntityData.class, LegalEntityDocument.class); /** * The meta-property for the {@code versioned} property. */ private final MetaProperty<LegalEntityDocument> _versioned = DirectMetaProperty.ofReadWrite( this, "versioned", WebLegalEntityData.class, LegalEntityDocument.class); /** * The meta-property for the {@code typeMap} property. */ @SuppressWarnings({"unchecked", "rawtypes" }) private final MetaProperty<BiMap<String, Class<? extends ManageableLegalEntity>>> _typeMap = DirectMetaProperty.ofReadWrite( this, "typeMap", WebLegalEntityData.class, (Class) BiMap.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, (DirectMetaPropertyMap) super.metaPropertyMap(), "legalEntityMaster", "securityMaster", "type", "uriLegalEntityId", "uriVersionId", "legalEntity", "versioned", "typeMap"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case -1944474242: // legalEntityMaster return _legalEntityMaster; case -887218750: // securityMaster return _securityMaster; case 3575610: // type return _type; case 580458539: // uriLegalEntityId return _uriLegalEntityId; case 666567687: // uriVersionId return _uriVersionId; case 41124860: // legalEntity return _legalEntity; case -1407102089: // versioned return _versioned; case -853107774: // typeMap return _typeMap; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends WebLegalEntityData> builder() { return new DirectBeanBuilder<WebLegalEntityData>(new WebLegalEntityData()); } @Override public Class<? extends WebLegalEntityData> beanType() { return WebLegalEntityData.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code legalEntityMaster} property. * @return the meta-property, not null */ public final MetaProperty<LegalEntityMaster> legalEntityMaster() { return _legalEntityMaster; } /** * The meta-property for the {@code securityMaster} property. * @return the meta-property, not null */ public final MetaProperty<SecurityMaster> securityMaster() { return _securityMaster; } /** * The meta-property for the {@code type} property. * @return the meta-property, not null */ public final MetaProperty<Class<?>> type() { return _type; } /** * The meta-property for the {@code uriLegalEntityId} property. * @return the meta-property, not null */ public final MetaProperty<String> uriLegalEntityId() { return _uriLegalEntityId; } /** * 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 legalEntity} property. * @return the meta-property, not null */ public final MetaProperty<LegalEntityDocument> legalEntity() { return _legalEntity; } /** * The meta-property for the {@code versioned} property. * @return the meta-property, not null */ public final MetaProperty<LegalEntityDocument> versioned() { return _versioned; } /** * The meta-property for the {@code typeMap} property. * @return the meta-property, not null */ public final MetaProperty<BiMap<String, Class<? extends ManageableLegalEntity>>> typeMap() { return _typeMap; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -1944474242: // legalEntityMaster return ((WebLegalEntityData) bean).getLegalEntityMaster(); case -887218750: // securityMaster return ((WebLegalEntityData) bean).getSecurityMaster(); case 3575610: // type return ((WebLegalEntityData) bean).getType(); case 580458539: // uriLegalEntityId return ((WebLegalEntityData) bean).getUriLegalEntityId(); case 666567687: // uriVersionId return ((WebLegalEntityData) bean).getUriVersionId(); case 41124860: // legalEntity return ((WebLegalEntityData) bean).getLegalEntity(); case -1407102089: // versioned return ((WebLegalEntityData) bean).getVersioned(); case -853107774: // typeMap return ((WebLegalEntityData) bean).getTypeMap(); } return super.propertyGet(bean, propertyName, quiet); } @SuppressWarnings("unchecked") @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -1944474242: // legalEntityMaster ((WebLegalEntityData) bean).setLegalEntityMaster((LegalEntityMaster) newValue); return; case -887218750: // securityMaster ((WebLegalEntityData) bean).setSecurityMaster((SecurityMaster) newValue); return; case 3575610: // type ((WebLegalEntityData) bean).setType((Class<?>) newValue); return; case 580458539: // uriLegalEntityId ((WebLegalEntityData) bean).setUriLegalEntityId((String) newValue); return; case 666567687: // uriVersionId ((WebLegalEntityData) bean).setUriVersionId((String) newValue); return; case 41124860: // legalEntity ((WebLegalEntityData) bean).setLegalEntity((LegalEntityDocument) newValue); return; case -1407102089: // versioned ((WebLegalEntityData) bean).setVersioned((LegalEntityDocument) newValue); return; case -853107774: // typeMap ((WebLegalEntityData) bean).setTypeMap((BiMap<String, Class<? extends ManageableLegalEntity>>) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((WebLegalEntityData) bean)._typeMap, "typeMap"); super.validate(bean); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }