/* $Id: AuthorBo.java,v 1.3 2005/06/15 16:11:46 m31 Exp $
 *
 * This file is part of the project "Hilbert II" - http://www.qedeq.org
 *
 * Copyright 2000-2005,  Michael Meyling <mime@qedeq.org>.
 *
 * "Hilbert II" is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */

package org.qedeq.kernel.bo.module;

import org.qedeq.kernel.base.module.Author;
import org.qedeq.kernel.base.module.Latex;
import org.qedeq.kernel.utility.EqualsUtility;


/**
 * Describes a specification of a module, that means its name, versions and
 * possible "physical" locations.
 *
 * @version $Revision: 1.3 $
 * @author  Michael Meyling
 */
public final class AuthorBo implements Author  {

    /** Author name. */
    private Latex name;

    /** Email address of author. */
    private String email;

    /**
     * Constructs an author.
     *
     * @param   name    Author name.
     * @param   email   Author's email address.
     */
    public AuthorBo(final Latex name, final String email) {
        this.name = name;
        this.email = email;
    }

    /**
     * Constructs an empty author.
     */
    public AuthorBo() {
        // nothing to do
    }

    /**
     * Set authors name.
     *
     * @param   name    Name of author.
     */
    public final void setName(final Latex name) {
        this.name = name;
    }

    public final Latex getName() {
        return name;
    }

    /**
     * Set authors email address.
     *
     * @param   email   Email address of author.
     */
    public final void setEmail(final String email) {
        this.email = email;
    }

    public final String getEmail() {
        return email;
    }

    public boolean equals(final Object obj) {
        if (!(obj instanceof AuthorBo)) {
            return false;
        }
        final AuthorBo other = (AuthorBo) obj;
        return  EqualsUtility.equals(getName(), other.getName())
            &&  EqualsUtility.equals(getEmail(), other.getEmail());
    }

    public int hashCode() {
        return (getName() != null ? getName().hashCode() : 0)
            ^ (getEmail() != null ? 1 ^ getEmail().hashCode() : 0);
    }

    public String toString() {
        return getName() + (getEmail() != null ? "<" + getEmail() + ">" : "");
    }

}
