package com.philisense.www.license;

import java.io.*;
import javax.security.auth.x500.*;

import com.philisense.www.xml.*;

import java.util.*;
import java.beans.*;

public class LicenseContent implements Serializable, Cloneable
{
    private static final long serialVersionUID = 1L;
    private X500Principal holder;
    private X500Principal issuer;
    private String subject;
    private Date issued;
    private Date notBefore;
    private Date notAfter;
    private String consumerType;
    private int consumerAmount;
    private String info;
    private Object extra;
    private transient PropertyChangeSupport propertySupport;
    
    public LicenseContent() {
        this.consumerAmount = 1;
    }
    
    protected Object clone() {
        try {
            return super.clone();
        }
        catch (CloneNotSupportedException ex) {
            throw new AssertionError((Object)ex);
        }
    }
    
    public X500Principal getHolder() {
        return this.holder;
    }
    
    public void setHolder(final X500Principal holder) {
        this.firePropertyChange("holder", this.holder, this.holder = holder);
    }
    
    public X500Principal getIssuer() {
        return this.issuer;
    }
    
    public void setIssuer(final X500Principal issuer) {
        this.firePropertyChange("issuer", this.issuer, this.issuer = issuer);
    }
    
    public String getSubject() {
        return this.subject;
    }
    
    public void setSubject(final String subject) {
        this.firePropertyChange("subject", this.subject, this.subject = subject);
    }
    
    private static Date clone(final Date date) {
        return (null != date) ? ((Date)date.clone()) : null;
    }
    
    public Date getIssued() {
        return clone(this.issued);
    }
    
    public void setIssued(final Date date) {
        final Date issued = this.issued;
        this.issued = clone(date);
        this.firePropertyChange("issued", clone(issued), clone(date));
    }
    
    public Date getNotBefore() {
        return clone(this.notBefore);
    }
    
    public void setNotBefore(final Date date) {
        final Date notBefore = this.notBefore;
        this.notBefore = clone(date);
        this.firePropertyChange("notBefore", clone(notBefore), clone(date));
    }
    
    public Date getNotAfter() {
        return clone(this.notAfter);
    }
    
    public void setNotAfter(final Date date) {
        final Date notAfter = this.notAfter;
        this.notAfter = clone(date);
        this.firePropertyChange("notAfter", clone(notAfter), clone(date));
    }
    
    public String getConsumerType() {
        return this.consumerType;
    }
    
    public void setConsumerType(final String consumerType) {
        this.firePropertyChange("consumerType", this.consumerType, this.consumerType = consumerType);
    }
    
    public int getConsumerAmount() {
        return this.consumerAmount;
    }
    
    public void setConsumerAmount(final int consumerAmount) {
        final int consumerAmount2 = this.consumerAmount;
        this.consumerAmount = consumerAmount;
        this.firePropertyChange("consumerAmount", new Integer(consumerAmount2), new Integer(consumerAmount));
    }
    
    public String getInfo() {
        return this.info;
    }
    
    public void setInfo(final String info) {
        this.firePropertyChange("info", this.info, this.info = info);
    }
    
    public Object getExtra() {
        return this.extra;
    }
    
    public void setExtra(final Object extra) {
        this.firePropertyChange("extra", this.extra, this.extra = extra);
    }
    
    @Override
    public boolean equals(final Object o) {
        if (!(o instanceof LicenseContent)) {
            return false;
        }
        final LicenseContent licenseContent = (LicenseContent)o;
        return this.getConsumerAmount() == licenseContent.getConsumerAmount() && equals(this.getConsumerType(), licenseContent.getConsumerType()) && equals(this.getExtra(), licenseContent.getExtra()) && equals(this.getHolder(), licenseContent.getHolder()) && equals(this.getInfo(), licenseContent.getInfo()) && equals(this.getIssued(), licenseContent.getIssued()) && equals(this.getIssuer(), licenseContent.getIssuer()) && equals(this.getNotAfter(), licenseContent.getNotAfter()) && equals(this.getNotBefore(), licenseContent.getNotBefore()) && equals(this.getSubject(), licenseContent.getSubject());
    }
    
    private static boolean equals(final Object o, final Object o2) {
        return o == o2 || (null != o && o.equals(o2));
    }
    
    @Override
    public int hashCode() {
        return 37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * 17 + this.getConsumerAmount()) + hash(this.getConsumerType())) + hash(this.getExtra())) + hash(this.getHolder())) + hash(this.getInfo())) + hash(this.getIssued())) + hash(this.getIssuer())) + hash(this.getNotAfter())) + hash(this.getNotBefore())) + hash(this.getSubject());
    }
    
    private static int hash(final Object o) {
        return (null == o) ? 0 : o.hashCode();
    }
    
    public final void addPropertyChangeListener(final PropertyChangeListener propertyChangeListener) {
        if (this.propertySupport == null) {
            this.propertySupport = new PropertyChangeSupport(this);
        }
        this.propertySupport.addPropertyChangeListener(propertyChangeListener);
    }
    
    public final void removePropertyChangeListener(final PropertyChangeListener propertyChangeListener) {
        if (null != this.propertySupport) {
            this.propertySupport.removePropertyChangeListener(propertyChangeListener);
        }
    }
    
    protected final void firePropertyChange(final PropertyChangeEvent propertyChangeEvent) {
        if (null != this.propertySupport) {
            this.propertySupport.firePropertyChange(propertyChangeEvent);
        }
    }
    
    protected final void firePropertyChange(final String s, final Object o, final Object o2) {
        if (null != this.propertySupport) {
            this.propertySupport.firePropertyChange(s, o, o2);
        }
    }
    
    static {
        PersistenceService.setPersistenceDelegate(X500Principal.class, (PersistenceDelegate)new DefaultPersistenceDelegate(new String[] { "name" }));
    }
}
