/*
 * Generated by XDoclet - Do not edit!
 */
package test.interfaces;

/**
 * Value object for Account.
 *
 * Notice, this object is used to represent the state of an 
 * Account object. This value object
 * Is not connected to the database in any way, it is just a normal object used 
 * as a container for data from an EJB. 
 *
 * @xdoclet-generated at 16-04-05
 * @copyright The XDoclet Team
 * @author XDoclet
 * @version 1.2.3
 */
public class AccountValue
   extends java.lang.Object
   implements java.io.Serializable, java.lang.Cloneable 
{

   private java.lang.Integer id;
   private boolean idHasBeenSet = false;

   private float totalBalance;
   private boolean totalBalanceHasBeenSet = false;

   private float balance;
   private boolean balanceHasBeenSet = false;

   private java.lang.String accountId;
   private boolean accountIdHasBeenSet = false;
   private test.interfaces.CustomerNormalValue OwnerNormalValue;
   private boolean OwnerNormalValueHasBeenSet = false;

   private test.interfaces.AccountPK primaryKey;

   public AccountValue()
   {
	  primaryKey = new test.interfaces.AccountPK();
   }

   public AccountValue( java.lang.Integer id,float totalBalance,float balance,java.lang.String accountId )
   {
       setId(id);
       setTotalBalance(totalBalance);
       setBalance(balance);
       setAccountId(accountId);
       primaryKey = new test.interfaces.AccountPK(this.getId());
   }

   /**
    * @deprecated use {@link #clone}
    */
   public AccountValue( AccountValue otherValue )
   {
	  this.id = otherValue.id;
	  idHasBeenSet = true;
	  this.totalBalance = otherValue.totalBalance;
	  totalBalanceHasBeenSet = true;
	  this.balance = otherValue.balance;
	  balanceHasBeenSet = true;
	  this.accountId = otherValue.accountId;
	  accountIdHasBeenSet = true;
	  this.OwnerNormalValue = otherValue.OwnerNormalValue;
	  OwnerNormalValueHasBeenSet = true;

	  primaryKey = new test.interfaces.AccountPK(this.getId());
   }

   public test.interfaces.AccountPK getPrimaryKey()
   {
	  return primaryKey;
   }

   public void setPrimaryKey( test.interfaces.AccountPK primaryKey)
   {
      // it's also nice to update PK object - just in case
      // somebody would ask for it later...
      this.primaryKey = primaryKey;
	  setId( primaryKey.id );
   }

   public java.lang.Integer getId()
   {
	  return this.id;
   }

   public void setId( java.lang.Integer id )
   {
	  this.id = id;
	  idHasBeenSet = true;

      primaryKey.setId(id);
   }

   public boolean idHasBeenSet(){
	  return idHasBeenSet;
   }
   public float getTotalBalance()
   {
	  return this.totalBalance;
   }

   private void setTotalBalance( float totalBalance )
   {
	  this.totalBalance = totalBalance;
	  totalBalanceHasBeenSet = true;

   }

   public float getBalance()
   {
	  return this.balance;
   }

   public void setBalance( float balance )
   {
	  this.balance = balance;
	  balanceHasBeenSet = true;

   }

   public boolean balanceHasBeenSet(){
	  return balanceHasBeenSet;
   }
   public java.lang.String getAccountId()
   {
	  return this.accountId;
   }

   private void setAccountId( java.lang.String accountId )
   {
	  this.accountId = accountId;
	  accountIdHasBeenSet = true;

   }

   public test.interfaces.CustomerNormalValue getOwnerNormalValue()
   {
	  return this.OwnerNormalValue;
   }
   public void setOwnerNormalValue( test.interfaces.CustomerNormalValue OwnerNormalValue )
   {
	  this.OwnerNormalValue = OwnerNormalValue;
	  OwnerNormalValueHasBeenSet = true;
   }
   public boolean ownerNormalValueHasBeenSet()
   {
	  return OwnerNormalValueHasBeenSet;
   }

   public String toString()
   {
	  StringBuffer str = new StringBuffer("{");

	  str.append("id=" + getId() + " " + "totalBalance=" + getTotalBalance() + " " + "balance=" + getBalance() + " " + "accountId=" + getAccountId());
	  str.append('}');

	  return(str.toString());
   }

   /**
    * A Value Object has an identity if the attributes making its Primary Key have all been set. An object without identity is never equal to any other object.
    *
    * @return true if this instance has an identity.
    */
   protected boolean hasIdentity()
   {
	  boolean ret = true;
	  ret = ret && idHasBeenSet;
	  return ret;
   }

   /**
    *
    * @deprecated use {@link #equals}
    */
   public boolean isIdentical(Object other)
   {
          if (other instanceof AccountValue)
          {
                 AccountValue that = (AccountValue) other;
                 boolean lEquals = true;
                 lEquals = lEquals && this.totalBalance == that.totalBalance;
                 lEquals = lEquals && this.balance == that.balance;
                 if( this.accountId == null )
                 {
                        lEquals = lEquals && ( that.accountId == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.accountId.equals( that.accountId );
                 }
                 if( this.OwnerNormalValue == null )
                 {
                        lEquals = lEquals && ( that.OwnerNormalValue == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.OwnerNormalValue.equals( that.OwnerNormalValue );
                 }

                 return lEquals;
          }
          else
          {
                 return false;
          }
   }

    public boolean equals(Object other) {

        //If it's not the correct type, clearly it isn't equal to this.
        if (!(other instanceof AccountValue)) { 
            return false;
        }

        return equals((AccountValue) other);
    }

    /**
     * This class is not using strict ordering. This means that the object is not Comparable, and
     * each check for equality will test all members for equality. We do not check collections for
     * equality however, so you would be wise to not use this if you have collection typed EJB References.
     */
    public boolean equals(AccountValue that) {

        //try to get lucky.
        if (this == that) {
            return true;
        }
        //this clearly isn't null.
        if(null == that) {
            return false;
        }

        if(this.id != that.id) {

            if( this.id == null || that.id == null ) {
                return false;
            }

            if(!this.id.equals(that.id)) {
                return false;
            }

        }

        if(this.totalBalance != that.totalBalance) {
            return false;
        }

        if(this.balance != that.balance) {
            return false;
        }

        if(this.accountId != that.accountId) {

            if( this.accountId == null || that.accountId == null ) {
                return false;
            }

            if(!this.accountId.equals(that.accountId)) {
                return false;
            }

        }

         if(this.OwnerNormalValue != that.OwnerNormalValue) {
            if((this.OwnerNormalValue == null) || (that.OwnerNormalValue == null)) {
                return false;
            }
            if(!this.OwnerNormalValue.equals(that.OwnerNormalValue)) {
                return false;
            }
         }

        return true;

    }

    public Object clone() throws java.lang.CloneNotSupportedException {
        AccountValue other = (AccountValue) super.clone();

        return other;
    }

    public ReadOnlyAccountValue getReadOnlyAccountValue() {
        return new ReadOnlyAccountValue();
    }

    public int hashCode(){
	  int result = 17;
      result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);

      result = 37*result + Float.floatToIntBits(totalBalance);

      result = 37*result + Float.floatToIntBits(balance);

      result = 37*result + ((this.accountId != null) ? this.accountId.hashCode() : 0);

	  result = 37*result + ((this.OwnerNormalValue != null) ? this.OwnerNormalValue.hashCode() : 0);

	  return result;
    }

    /**
     * Covariant function so the compiler can choose the proper one at compile time,
     * eliminates the need for XDoclet to really understand compiletime typing.
     *
     * Read only collections need to be synchronized. Once we start giving out handles
     * to these collections, they'll be used in other threads sooner or later. 
     */
    private static java.util.Collection wrapCollection(java.util.Collection input) {
        return java.util.Collections.synchronizedCollection(input);
    }
    /**
     * Covariant function so the compiler can choose the proper one at compile time,
     * eliminates the need for XDoclet to really understand compiletime typing.
     *
     * Read only collections need to be synchronized. Once we start giving out handles
     * to these collections, they'll be used in other threads sooner or later. 
     */
    private static java.util.Set wrapCollection(java.util.Set input) {
        return java.util.Collections.synchronizedSet(input);
    }
    /**
     * Covariant function. This is used in covariant form so that the compiler
     * can do some of our conditional branches for us. If I made these functions
     * have different names, then XDoclet would have to choose between them based on 
     * compiletime types, that wouldn't be easy. 
     */
    private static java.util.Collection wrapReadOnly(java.util.Collection input) {
        return java.util.Collections.unmodifiableCollection(input);
    }
    /**
     * Covariant function. This is used in covariant form so that the compiler
     * can do some of our conditional branches for us. If I made these functions
     * have different names, then XDoclet would have to choose between them based on 
     * compiletime types, that wouldn't be easy. 
     */
    private static java.util.Set wrapReadOnly(java.util.Set input) {
        return java.util.Collections.unmodifiableSet(input);
    }

    private final class ReadOnlyAccountValue 
    implements java.lang.Cloneable, java.io.Serializable 
    {
        private AccountValue underlying() {
            return AccountValue.this;
        }

       public java.lang.Integer getId() {
              return underlying().id;
       }

       public float getTotalBalance() {
              return underlying().totalBalance;
       }

       public float getBalance() {
              return underlying().balance;
       }

       public java.lang.String getAccountId() {
              return underlying().accountId;
       }

       public test.interfaces.CustomerNormalValue getOwnerNormalValue()
       {
              return underlying().OwnerNormalValue;
       }

        public int hashCode() {
            return 101 * underlying().hashCode();
        }

        public boolean equals(Object o) {
            if(o instanceof ReadOnlyAccountValue) {
                return this.equals((ReadOnlyAccountValue) o);
            }
            return false;
        }

        public boolean equals(ReadOnlyAccountValue that) {
            if(null == that) {
                return false;
            }

            return this.underlying().equals(that.underlying());
        }

    }

}
