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

Java tutorial

Introduction

Here is the source code for com.sfs.whichdoctor.beans.ContactBean.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 ContactBean.
 *
 * @author David Harrison 30th May 2003
 */
public class ContactBean extends WhichDoctorBean {

    /** The unique serial version UID for the class. */
    private static final long serialVersionUID = -3546207862492272208L;

    /** The reference guid. */
    private int referenceGUID;

    /** The contact type. */
    private String contactType;

    /** The contact class. */
    private String contactClass;

    /** The primary. */
    private boolean primary;

    /** The returned mail. */
    private boolean returnedMail;

    /** The request no mail. */
    private boolean requestNoMail;

    /**
     * Sets the reference guid.
     *
     * @param referenceGUIDVal the new reference guid
     */
    public final void setReferenceGUID(final int referenceGUIDVal) {
        this.referenceGUID = referenceGUIDVal;
    }

    /**
     * Gets the reference guid.
     *
     * @return the reference guid
     */
    public final int getReferenceGUID() {
        return this.referenceGUID;
    }

    /**
     * Sets the contact class.
     *
     * @param contactClassVal the new contact class
     */
    public final void setContactClass(final String contactClassVal) {
        this.contactClass = contactClassVal;
    }

    /**
     * Gets the contact class.
     *
     * @return the contact class
     */
    public final String getContactClass() {
        if (this.contactClass == null) {
            this.contactClass = "";
        }
        return this.contactClass.trim();
    }

    /**
     * Sets the contact type.
     *
     * @param contactTypeVal the new contact type
     */
    public final void setContactType(final String contactTypeVal) {
        this.contactType = contactTypeVal;
    }

    /**
     * Gets the contact type.
     *
     * @return the contact type
     */
    public final String getContactType() {
        if (this.contactType == null) {
            this.contactType = "";
        }
        return this.contactType.trim();
    }

    /**
     * Sets the primary.
     *
     * @param primaryVal the new primary
     */
    public final void setPrimary(final boolean primaryVal) {
        this.primary = primaryVal;
    }

    /**
     * Gets the primary.
     *
     * @return the primary
     */
    public final boolean getPrimary() {
        return this.primary;
    }

    /**
     * Sets the returned mail.
     *
     * @param returnedMailVal the new returned mail
     */
    public final void setReturnedMail(final boolean returnedMailVal) {
        this.returnedMail = returnedMailVal;
    }

    /**
     * Gets the returned mail.
     *
     * @return the returned mail
     */
    public final boolean getReturnedMail() {
        return this.returnedMail;
    }

    /**
     * Sets the request no mail.
     *
     * @param requestNoMailVal the new request no mail
     */
    public final void setRequestNoMail(final boolean requestNoMailVal) {
        this.requestNoMail = requestNoMailVal;
    }

    /**
     * Gets the request no mail.
     *
     * @return the request no mail
     */
    public final boolean getRequestNoMail() {
        return this.requestNoMail;
    }

    /**
     * Gets the status.
     *
     * @param personStatus the person status
     *
     * @return the status
     */
    public final String getStatus(final String personStatus) {

        StringBuffer contactStatus = new StringBuffer();

        if (this.returnedMail) {
            if (contactStatus.length() > 0) {
                contactStatus.append(", ");
            }
            contactStatus.append("returned mail");
        }
        if (this.requestNoMail) {
            if (contactStatus.length() > 0) {
                contactStatus.append(", ");
            }
            contactStatus.append("no mail requested");
        }
        if (StringUtils.equalsIgnoreCase(personStatus, "Deceased")) {
            if (contactStatus.length() > 0) {
                contactStatus.append(", ");
            }
            contactStatus.append("deceased");
        }
        return capitalise(contactStatus.toString());
    }

    /**
     * Capitalise.
     *
     * @param s the s
     *
     * @return the string
     */
    private static String capitalise(final String s) {
        if (s.length() == 0) {
            return s;
        }
        return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
    }

}