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

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

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

   private java.lang.String street;
   private boolean streetHasBeenSet = false;

   private java.lang.String city;
   private boolean cityHasBeenSet = false;

   private int readOnly;
   private boolean readOnlyHasBeenSet = false;

   private java.lang.String primaryKey;

   public AddressValue()
   {
   }

   public AddressValue( java.lang.String id,java.lang.String street,java.lang.String city,int readOnly )
   {
       setId(id);
       setStreet(street);
       setCity(city);
       setReadOnly(readOnly);
	   primaryKey = this.getId();
   }

   /**
    * @deprecated use {@link #clone}
    */
   public AddressValue( AddressValue otherValue )
   {
	  this.id = otherValue.id;
	  idHasBeenSet = true;
	  this.street = otherValue.street;
	  streetHasBeenSet = true;
	  this.city = otherValue.city;
	  cityHasBeenSet = true;
	  this.readOnly = otherValue.readOnly;
	  readOnlyHasBeenSet = true;

	  primaryKey = this.getId();
   }

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

   public void setPrimaryKey( java.lang.String 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.String getId()
   {
	  return this.id;
   }

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

      primaryKey = id;
   }

   public boolean idHasBeenSet(){
	  return idHasBeenSet;
   }
   public java.lang.String getStreet()
   {
	  return this.street;
   }

   private void setStreet( java.lang.String street )
   {
	  this.street = street;
	  streetHasBeenSet = true;

   }

   public java.lang.String getCity()
   {
	  return this.city;
   }

   private void setCity( java.lang.String city )
   {
	  this.city = city;
	  cityHasBeenSet = true;

   }

   public int getReadOnly()
   {
	  return this.readOnly;
   }

   private void setReadOnly( int readOnly )
   {
	  this.readOnly = readOnly;
	  readOnlyHasBeenSet = true;

   }

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

	  str.append("id=" + getId() + " " + "street=" + getStreet() + " " + "city=" + getCity() + " " + "readOnly=" + getReadOnly());
	  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 AddressValue)
          {
                 AddressValue that = (AddressValue) other;
                 boolean lEquals = true;
                 if( this.street == null )
                 {
                        lEquals = lEquals && ( that.street == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.street.equals( that.street );
                 }
                 if( this.city == null )
                 {
                        lEquals = lEquals && ( that.city == null );
                 }
                 else
                 {
                        lEquals = lEquals && this.city.equals( that.city );
                 }
                 lEquals = lEquals && this.readOnly == that.readOnly;

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

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

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

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

        }

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

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

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

        }

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

        return true;

    }

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

        return other;
    }

    public ReadOnlyAddressValue getReadOnlyAddressValue() {
        return new ReadOnlyAddressValue();
    }

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

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

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

      result = 37*result + (int) readOnly;

	  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 ReadOnlyAddressValue 
    implements java.lang.Cloneable, java.io.Serializable 
    {
        private AddressValue underlying() {
            return AddressValue.this;
        }

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

       public java.lang.String getStreet() {
              return underlying().street;
       }

       public java.lang.String getCity() {
              return underlying().city;
       }

       public int getReadOnly() {
              return underlying().readOnly;
       }

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

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

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

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

    }

}
