/* $Id: ImportBo.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.Import;
import org.qedeq.kernel.base.module.Specification;
import org.qedeq.kernel.utility.EqualsUtility;


/**
 * Module import. Every needed module must be referenced as an module import.
 *
 * @version $Revision: 1.3 $
 * @author  Michael Meyling
 */
public final class ImportBo implements Import  {

    /** Label for the imported module. All references to that module must have this prefix. */
    private String label;

    /** Specification of imported module. Includes location information. */
    private Specification specification;

    /**
     * Constructs a new import.
     *
     * @param   label           Label for this import. All references to that module must have
     *                          this prefix.
     * @param   specification   Import specification. Includes location information.
     */
    public ImportBo(final String label, final Specification specification) {
        this.label = label;
        this.specification = specification;
    }

    /**
     * Constructs an empty import.
     */
    public ImportBo() {
        // nothing to do
    }

    /**
     * Set label for this import. All references to that module must have this prefix.
     *
     * @param   label   Module reference prefix.
     */
    public final void setLabel(final String label) {
        this.label = label;
    }

    public final String getLabel() {
        return label;
    }

    /**
     * Set import module specification.
     *
     * @param   specification   Import module specifiaction.
     */
    public final void setSpecification(final Specification specification) {
        this.specification = specification;
    }

    public final Specification getSpecification() {
        return specification;
    }

    public boolean equals(final Object obj) {
        if (!(obj instanceof ImportBo)) {
            return false;
        }
        final ImportBo other = (ImportBo) obj;
        return  EqualsUtility.equals(getLabel(), other.getLabel())
            &&  EqualsUtility.equals(getSpecification(), other.getSpecification());
    }

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

    public String toString() {
        return label + ":" + specification;
    }

}
