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

/**
 * Value object for Employee.
 *
 * Notice, this object is used to represent the state of an 
 * Employee 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 EmployeeValue
   extends java.lang.Object
   implements java.io.Serializable, java.lang.Cloneable 
{

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

   private java.lang.String name;
   private boolean nameHasBeenSet = false;
   private test.ejb.cmr.EmployeeAddressValue HomeAddress;
   private boolean HomeAddressHasBeenSet = false;
   private test.ejb.cmr.EmployeeAddressValue WorkAddress;
   private boolean WorkAddressHasBeenSet = false;

   private java.lang.Integer primaryKey;

   public EmployeeValue()
   {
   }

   public EmployeeValue( java.lang.Integer id,java.lang.String name )
   {
       setId(id);
       setName(name);
	   primaryKey = this.getId();
   }

   /**
    * @deprecated use {@link #clone}
    */
   public EmployeeValue( EmployeeValue otherValue )
   {
	  this.id = otherValue.id;
	  idHasBeenSet = true;
	  this.name = otherValue.name;
	  nameHasBeenSet = true;
	  this.HomeAddress = otherValue.HomeAddress;
	  HomeAddressHasBeenSet = true;
	  this.WorkAddress = otherValue.WorkAddress;
	  WorkAddressHasBeenSet = true;

	  primaryKey = this.getId();
   }

   public java.lang.Integer getPrimaryKey()
   {
	  return primaryKey;
   }

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

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

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

      primaryKey = id;
   }

   public boolean idHasBeenSet(){
	  return idHasBeenSet;
   }
   public java.lang.String getName()
   {
	  return this.name;
   }

   public void setName( java.lang.String name )
   {
	  this.name = name;
	  nameHasBeenSet = true;

   }

   public boolean nameHasBeenSet(){
	  return nameHasBeenSet;
   }

   public test.ejb.cmr.EmployeeAddressValue getHomeAddress()
   {
	  return this.HomeAddress;
   }
   public void setHomeAddress( test.ejb.cmr.EmployeeAddressValue HomeAddress )
   {
	  this.HomeAddress = HomeAddress;
	  HomeAddressHasBeenSet = true;
   }
   public boolean homeAddressHasBeenSet()
   {
	  return HomeAddressHasBeenSet;
   }
   public test.ejb.cmr.EmployeeAddressValue getWorkAddress()
   {
	  return this.WorkAddress;
   }
   public void setWorkAddress( test.ejb.cmr.EmployeeAddressValue WorkAddress )
   {
	  this.WorkAddress = WorkAddress;
	  WorkAddressHasBeenSet = true;
   }
   public boolean workAddressHasBeenSet()
   {
	  return WorkAddressHasBeenSet;
   }

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

	  str.append("id=" + getId() + " " + "name=" + getName());
	  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()
   {
	  return idHasBeenSet;
   }

   /**
    *
    * @deprecated use {@link #equals}
    */
   public boolean isIdentical(Object other)
   {
          if (other instanceof EmployeeValue)
          {
                 EmployeeValue that = (EmployeeValue) other;
                 boolean lEquals = true;
                 if( this.id == null )
                 {
                        lEquals = lEquals && ( that.id == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.id.equals( that.id );
                 }
                 if( this.name == null )
                 {
                        lEquals = lEquals && ( that.name == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.name.equals( that.name );
                 }
                 if( this.HomeAddress == null )
                 {
                        lEquals = lEquals && ( that.HomeAddress == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.HomeAddress.equals( that.HomeAddress );
                 }
                 if( this.WorkAddress == null )
                 {
                        lEquals = lEquals && ( that.WorkAddress == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.WorkAddress.equals( that.WorkAddress );
                 }

                 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 EmployeeValue)) { 
            return false;
        }

        return equals((EmployeeValue) 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(EmployeeValue 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.name != that.name) {

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

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

        }

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

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

        return true;

    }

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

        return other;
    }

    public ReadOnlyEmployeeValue getReadOnlyEmployeeValue() {
        return new ReadOnlyEmployeeValue();
    }

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

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

	  result = 37*result + ((this.HomeAddress != null) ? this.HomeAddress.hashCode() : 0);
	  result = 37*result + ((this.WorkAddress != null) ? this.WorkAddress.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 ReadOnlyEmployeeValue 
    implements java.lang.Cloneable, java.io.Serializable 
    {
        private EmployeeValue underlying() {
            return EmployeeValue.this;
        }

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

       public java.lang.String getName() {
              return underlying().name;
       }

       public test.ejb.cmr.EmployeeAddressValue getHomeAddress()
       {
              return underlying().HomeAddress;
       }
       public test.ejb.cmr.EmployeeAddressValue getWorkAddress()
       {
              return underlying().WorkAddress;
       }

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

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

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

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

    }

}
