/** * Copyright (C) 2014 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.core.legalentity; import java.util.Map; import java.util.Set; 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.DirectMetaBean; import org.joda.beans.impl.direct.DirectMetaProperty; import org.joda.beans.impl.direct.DirectMetaPropertyMap; import com.opengamma.id.ObjectId; /** * Account of a legal entity */ @BeanDefinition public class Account implements Bean { @PropertyDefinition private String _name; @PropertyDefinition private ObjectId _portfolio; //TODO refactor <ObjectId> to <PortfolioLink> when PortfolioLink is ready. //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code Account}. * @return the meta-bean, not null */ public static Account.Meta meta() { return Account.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(Account.Meta.INSTANCE); } @Override public Account.Meta metaBean() { return Account.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 name. * @return the value of the property */ public String getName() { return _name; } /** * Sets the name. * @param name the new value of the property */ public void setName(String name) { this._name = name; } /** * Gets the the {@code name} property. * @return the property, not null */ public final Property<String> name() { return metaBean().name().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the portfolio. * @return the value of the property */ public ObjectId getPortfolio() { return _portfolio; } /** * Sets the portfolio. * @param portfolio the new value of the property */ public void setPortfolio(ObjectId portfolio) { this._portfolio = portfolio; } /** * Gets the the {@code portfolio} property. * @return the property, not null */ public final Property<ObjectId> portfolio() { return metaBean().portfolio().createProperty(this); } //----------------------------------------------------------------------- @Override public Account clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { Account other = (Account) obj; return JodaBeanUtils.equal(getName(), other.getName()) && JodaBeanUtils.equal(getPortfolio(), other.getPortfolio()); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(getName()); hash = hash * 31 + JodaBeanUtils.hashCode(getPortfolio()); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(96); buf.append("Account{"); 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("name").append('=').append(JodaBeanUtils.toString(getName())).append(',').append(' '); buf.append("portfolio").append('=').append(JodaBeanUtils.toString(getPortfolio())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code Account}. */ 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 name} property. */ private final MetaProperty<String> _name = DirectMetaProperty.ofReadWrite( this, "name", Account.class, String.class); /** * The meta-property for the {@code portfolio} property. */ private final MetaProperty<ObjectId> _portfolio = DirectMetaProperty.ofReadWrite( this, "portfolio", Account.class, ObjectId.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, null, "name", "portfolio"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 3373707: // name return _name; case 1121781064: // portfolio return _portfolio; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends Account> builder() { return new DirectBeanBuilder<Account>(new Account()); } @Override public Class<? extends Account> beanType() { return Account.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code name} property. * @return the meta-property, not null */ public final MetaProperty<String> name() { return _name; } /** * The meta-property for the {@code portfolio} property. * @return the meta-property, not null */ public final MetaProperty<ObjectId> portfolio() { return _portfolio; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3373707: // name return ((Account) bean).getName(); case 1121781064: // portfolio return ((Account) bean).getPortfolio(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 3373707: // name ((Account) bean).setName((String) newValue); return; case 1121781064: // portfolio ((Account) bean).setPortfolio((ObjectId) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }