com.sfs.whichdoctor.beans.EmailBean.java Source code

Java tutorial

Introduction

Here is the source code for com.sfs.whichdoctor.beans.EmailBean.java

Source

/*******************************************************************************
 * Copyright (c) 2009 David Harrison.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl-3.0.html
 *
 * Contributors:
 *     David Harrison - initial API and implementation
 ******************************************************************************/
package com.sfs.whichdoctor.beans;

import org.apache.commons.lang.StringUtils;

/**
 * The Class EmailBean.
 *
 * @author David Harrison 30th May 2003 Modified 9th April 2005
 */
public class EmailBean extends ContactBean {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** The email. */
    private String email;

    /** The email questions. */
    private boolean emailQuestions;

    /**
     * Sets the email.
     *
     * @param emailVal the new email
     */
    public final void setEmail(final String emailVal) {
        this.email = emailVal;
    }

    /**
     * Gets the email.
     *
     * @return the email
     */
    public final String getEmail() {
        if (this.email == null) {
            this.email = "";
        }
        return this.email;
    }

    /**
     * Sets the email questions.
     *
     * @param emailQuestionsVal the new email questions
     */
    public final void setEmailQuestions(final boolean emailQuestionsVal) {
        this.emailQuestions = emailQuestionsVal;
    }

    /**
     * Gets the email questions.
     *
     * @return the email questions
     */
    public final boolean getEmailQuestions() {
        return this.emailQuestions;
    }

    /**
     * Compare the existing email address with the updated version. If the two
     * are different return true.
     *
     * @param updated the updated
     *
     * @return boolean different
     */
    public final boolean compare(final EmailBean updated) {
        boolean different = false;

        if (updated == null) {
            different = true;
        } else {
            if (!StringUtils.equals(this.getEmail(), updated.getEmail())) {
                different = true;
            }
            if (this.getPrimary() != updated.getPrimary()) {
                different = true;
            }
            if (!StringUtils.equals(this.getContactType(), updated.getContactType())) {
                different = true;
            }
        }
        return different;
    }
}