/*
 * 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 = "contacts")
@NamedQueries({@NamedQuery(name = "Contacts.findByContactID",query = "SELECT c FROM Contacts c WHERE c.contactID = :contactID"),@NamedQuery(name = "Contacts.findByContactType",query = "SELECT c FROM Contacts c WHERE c.contactType = :contactType"),@NamedQuery(name = "Contacts.findBySerialNumber",query = "SELECT c FROM Contacts c WHERE c.serialNumber = :serialNumber"),@NamedQuery(name = "Contacts.findByContactDescription",query = "SELECT c FROM Contacts c WHERE c.contactDescription = :contactDescription")})
public class Contacts 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 = "ContactType",nullable = false)
    private short contactType;
    @Column(name = "SerialNumber",nullable = false)
    private short serialNumber;
    @Column(name = "ContactDescription",nullable = false)
    private String contactDescription;

    public Contacts()
    {
    }

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

    public Contacts(Long contactID,short contactType,short serialNumber,String contactDescription)
    {
        this.contactID = contactID;
        this.contactType = contactType;
        this.serialNumber = serialNumber;
        this.contactDescription = contactDescription;
    }

    public Long getContactID()
    {
        return contactID;
    }

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

    public short getContactType()
    {
        return contactType;
    }

    public void setContactType(short contactType)
    {
        short oldContactType = this.contactType;
        this.contactType = contactType;
        changeSupport.firePropertyChange("contactType",oldContactType,contactType);
    }

    public short getSerialNumber()
    {
        return serialNumber;
    }

    public void setSerialNumber(short serialNumber)
    {
        short oldSerialNumber = this.serialNumber;
        this.serialNumber = serialNumber;
        changeSupport.firePropertyChange("serialNumber",oldSerialNumber,serialNumber);
    }

    public String getContactDescription()
    {
        return contactDescription;
    }

    public void setContactDescription(String contactDescription)
    {
        String oldContactDescription = this.contactDescription;
        this.contactDescription = contactDescription;
        changeSupport.firePropertyChange("contactDescription",oldContactDescription,contactDescription);
    }

    @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 Contacts))
        {
            return false;
        }
        Contacts other = (Contacts)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.Contacts[contactID=" + contactID + "]";
    }

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

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

}
