001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002 *
003 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
004 *
005 * "Hilbert II" is free software; you can redistribute
006 * it and/or modify it under the terms of the GNU General Public
007 * License as published by the Free Software Foundation; either
008 * version 2 of the License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU General Public License for more details.
014 */
015
016 package org.qedeq.kernel.se.dto.module;
017
018 import org.qedeq.base.utility.EqualsUtility;
019 import org.qedeq.kernel.se.base.module.Import;
020 import org.qedeq.kernel.se.base.module.Specification;
021
022
023 /**
024 * Module import. Every needed module must be referenced as an module import.
025 *
026 * @author Michael Meyling
027 */
028 public class ImportVo implements Import {
029
030 /** Label for the imported module. All references to that module must have this prefix. */
031 private String label;
032
033 /** Specification of imported module. Includes location information. */
034 private Specification specification;
035
036 /**
037 * Constructs a new import.
038 *
039 * @param label Label for this import. All references to that module must
040 * have this prefix.
041 * @param specification Import specification. Includes location information.
042 */
043 public ImportVo(final String label, final SpecificationVo specification) {
044 this.label = label;
045 this.specification = specification;
046 }
047
048 /**
049 * Constructs an empty import.
050 */
051 public ImportVo() {
052 // nothing to do
053 }
054
055 /**
056 * Set label for this import module. All references to this module must have this
057 * prefix.
058 *
059 * @param label Prefix for this imported module.
060 */
061 public final void setLabel(final String label) {
062 this.label = label;
063 }
064
065 public final String getLabel() {
066 return label;
067 }
068
069 /**
070 * Set specification of this imported module. Contains location information.
071 *
072 * @param specification Module specification.
073 */
074 public final void setSpecification(final SpecificationVo specification) {
075 this.specification = specification;
076 }
077
078 public final Specification getSpecification() {
079 return specification;
080 }
081
082 public boolean equals(final Object obj) {
083 if (!(obj instanceof ImportVo)) {
084 return false;
085 }
086 final ImportVo other = (ImportVo) obj;
087 return EqualsUtility.equals(getLabel(), other.getLabel())
088 && EqualsUtility.equals(getSpecification(), other.getSpecification());
089 }
090
091 public int hashCode() {
092 return (getLabel() != null ? getLabel().hashCode() : 0)
093 ^ (getSpecification() != null ? 1 ^ getSpecification().hashCode() : 0);
094 }
095
096 public String toString() {
097 return label + ":" + specification;
098 }
099
100 }
|