net.kamhon.ieagle.function.email.vo.Emailq.java Source code

Java tutorial

Introduction

Here is the source code for net.kamhon.ieagle.function.email.vo.Emailq.java

Source

/*
 * Copyright 2012 Eng Kam Hon (kamhon@gmail.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.kamhon.ieagle.function.email.vo;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import net.kamhon.ieagle.vo.annotation.ToTrim;
import net.kamhon.ieagle.vo.annotation.ToUpperCase;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "app_emailq")
@Access(AccessType.FIELD)
public class Emailq extends net.kamhon.ieagle.vo.VoBase {
    private static final long serialVersionUID = 1L;

    public static final String EMAIL_STATUS_PENDING = "PEND";
    public static final String EMAIL_STATUS_SENT = "SENT";

    public static final String TYPE_TEXT = "TEXT";
    public static final String TYPE_HTML = "HTML";

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "email_id", unique = true, nullable = false, length = 32)
    private String emailId;

    @ToTrim
    @ToUpperCase
    @Column(name = "email_from", length = 100, nullable = false)
    private String emailFrom;

    @ToTrim
    @ToUpperCase
    @Column(name = "email_to", length = 255, nullable = false)
    private String emailTo;

    @ToTrim
    @ToUpperCase
    @Column(name = "email_cc", length = 255)
    private String emailCc;

    @ToTrim
    @ToUpperCase
    @Column(name = "email_bcc", length = 255)
    private String emailBcc;

    @ToTrim
    @Column(name = "email_subject", length = 200, nullable = false)
    private String emailSubject;

    @ToTrim
    @Column(name = "email_msg")
    private String emailMsg;

    @ToTrim
    @ToUpperCase
    @Column(name = "email_type", length = 5, nullable = false)
    private String emailType;

    @ToTrim
    @ToUpperCase
    @Column(name = "email_status", length = 5, nullable = false)
    private String emailStatus;

    @Column(name = "email_retry", nullable = false)
    private Integer emailRetry;

    public Emailq() {
    }

    public Emailq(String emailId) {
        this.emailId = emailId;
    }

    public Emailq(boolean defaultValue) {
        if (defaultValue) {
            emailRetry = 0;
            emailStatus = EMAIL_STATUS_PENDING;
        }
    }

    public String getEmailId() {
        return emailId;
    }

    public String getEmailFrom() {
        return emailFrom;
    }

    public String getEmailTo() {
        return emailTo;
    }

    public String getEmailCc() {
        return emailCc;
    }

    public String getEmailBcc() {
        return emailBcc;
    }

    public String getEmailSubject() {
        return emailSubject;
    }

    public String getEmailMsg() {
        return emailMsg;
    }

    public String getEmailStatus() {
        return emailStatus;
    }

    public Integer getEmailRetry() {
        return emailRetry;
    }

    public void setEmailId(String emailId) {
        this.emailId = emailId;
    }

    public void setEmailFrom(String emailFrom) {
        this.emailFrom = emailFrom;
    }

    public void setEmailTo(String emailTo) {
        this.emailTo = emailTo;
    }

    public void setEmailCc(String emailCc) {
        this.emailCc = emailCc;
    }

    public void setEmailBcc(String emailBcc) {
        this.emailBcc = emailBcc;
    }

    public void setEmailSubject(String emailSubject) {
        this.emailSubject = emailSubject;
    }

    public void setEmailMsg(String emailMsg) {
        this.emailMsg = emailMsg;
    }

    public void setEmailStatus(String emailStatus) {
        this.emailStatus = emailStatus;
    }

    public void setEmailRetry(Integer emailRetry) {
        this.emailRetry = emailRetry;
    }

    public String getEmailType() {
        return emailType;
    }

    public void setEmailType(String emailType) {
        this.emailType = emailType;
    }

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final Emailq other = (Emailq) obj;
        if (this.emailId == null) {
            if (other.emailId != null)
                return false;
        } else if (!this.emailId.equals(other.emailId))
            return false;
        return true;
    }

    public int hashCode() {
        HashCodeBuilder hashCode = new HashCodeBuilder();
        if (emailId != null)
            hashCode.append(emailId);
        return hashCode.toHashCode();
    }
}