/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.actiwaves.swing.TestSwing;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author sudeep.panchal
 */
@Entity
@Table(name = "address")
@NamedQueries( {@NamedQuery(name = "Address.findByContactID",query = "SELECT a FROM Address a WHERE a.contactID = :contactID"),@NamedQuery(name = "Address.findByAddressType",query = "SELECT a FROM Address a WHERE a.addressType = :addressType"),@NamedQuery(name = "Address.findByAddressFormatType",query = "SELECT a FROM Address a WHERE a.addressFormatType = :addressFormatType"),@NamedQuery(name = "Address.findByAddress",query = "SELECT a FROM Address a WHERE a.address = :address"),@NamedQuery(name = "Address.findByPinCode",query = "SELECT a FROM Address a WHERE a.pinCode = :pinCode"),@NamedQuery(name = "Address.findByCityCode",query = "SELECT a FROM Address a WHERE a.cityCode = :cityCode"),@NamedQuery(name = "Address.findByStateID",query = "SELECT a FROM Address a WHERE a.stateID = :stateID"),@NamedQuery(name = "Address.findByCountryCode",query = "SELECT a FROM Address a WHERE a.countryCode = :countryCode")})
public class Address implements Serializable {
    @Transient
    private
    PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final
    long serialVersionUID = 1L;
    @Id
    @Column(name = "ContactID",nullable = false)
    private
    Long contactID;
    @Column(name = "AddressType",nullable = false)
    private
    short addressType;
    @Column(name = "AddressFormatType",nullable = false)
    private
    short addressFormatType;
    @Column(name = "Address",nullable = false)
    private
    String address;
    @Column(name = "PinCode",nullable = false)
    private
    String pinCode;
    @Column(name = "CityCode",nullable = false)
    private
    long cityCode;
    @Column(name = "StateID",nullable = false)
    private
    short stateID;
    @Column(name = "CountryCode",nullable = false)
    private
    short countryCode;

    public
    Address()
    {
    }

    public
    Address(Long contactID)
    {
        this.contactID = contactID;
    }

    public
    Address(Long contactID,short addressType,short addressFormatType,String address,String pinCode,long cityCode,short stateID,short countryCode)
    {
        this.contactID = contactID;
        this.addressType = addressType;
        this.addressFormatType = addressFormatType;
        this.address = address;
        this.pinCode = pinCode;
        this.cityCode = cityCode;
        this.stateID = stateID;
        this.countryCode = countryCode;
    }

    public
    Long getContactID()
    {
        return contactID;
    }

    public
    void setContactID(Long contactID)
    {
        Long oldContactID = this.contactID;
        this.contactID = contactID;
        changeSupport.firePropertyChange("contactID",oldContactID,contactID);
    }

    public
    short getAddressType()
    {
        return addressType;
    }

    public
    void setAddressType(short addressType)
    {
        short oldAddressType = this.addressType;
        this.addressType = addressType;
        changeSupport.firePropertyChange("addressType",oldAddressType,addressType);
    }

    public
    short getAddressFormatType()
    {
        return addressFormatType;
    }

    public
    void setAddressFormatType(short addressFormatType)
    {
        short oldAddressFormatType = this.addressFormatType;
        this.addressFormatType = addressFormatType;
        changeSupport.firePropertyChange("addressFormatType",oldAddressFormatType,addressFormatType);
    }

    public
    String getAddress()
    {
        return address;
    }

    public
    void setAddress(String address)
    {
        String oldAddress = this.address;
        this.address = address;
        changeSupport.firePropertyChange("address",oldAddress,address);
    }

    public
    String getPinCode()
    {
        return pinCode;
    }

    public
    void setPinCode(String pinCode)
    {
        String oldPinCode = this.pinCode;
        this.pinCode = pinCode;
        changeSupport.firePropertyChange("pinCode",oldPinCode,pinCode);
    }

    public
    long getCityCode()
    {
        return cityCode;
    }

    public
    void setCityCode(long cityCode)
    {
        long oldCityCode = this.cityCode;
        this.cityCode = cityCode;
        changeSupport.firePropertyChange("cityCode",oldCityCode,cityCode);
    }

    public
    short getStateID()
    {
        return stateID;
    }

    public
    void setStateID(short stateID)
    {
        short oldStateID = this.stateID;
        this.stateID = stateID;
        changeSupport.firePropertyChange("stateID",oldStateID,stateID);
    }

    public
    short getCountryCode()
    {
        return countryCode;
    }

    public
    void setCountryCode(short countryCode)
    {
        short oldCountryCode = this.countryCode;
        this.countryCode = countryCode;
        changeSupport.firePropertyChange("countryCode",oldCountryCode,countryCode);
    }

    @Override
    public
    int hashCode()
    {
        int hash = 0;
        hash += (contactID != null ? contactID.hashCode() : 0);
        return hash;
    }

    @Override
    public
    boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if(!(object instanceof Address))
        {
            return false;
        }
        Address other = (Address)object;
        if((this.contactID == null && other.contactID != null) || (this.contactID != null && !this.contactID.equals(other.contactID)))
        {
            return false;
        }
        return true;
    }

    @Override
    public
    String toString()
    {
        return "com.actiwaves.swing.TestSwing.Address[contactID=" + contactID + "]";
    }

    public
    void addPropertyChangeListener(PropertyChangeListener listener)
    {
        changeSupport.addPropertyChangeListener(listener);
    }

    public
    void removePropertyChangeListener(PropertyChangeListener listener)
    {
        changeSupport.addPropertyChangeListener(listener);
    }

}
