| 1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org |
| 2 | * |
| 3 | * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. |
| 4 | * |
| 5 | * "Hilbert II" is free software; you can redistribute |
| 6 | * it and/or modify it under the terms of the GNU General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | package org.qedeq.kernel.se.dto.module; |
| 17 | |
| 18 | import org.qedeq.base.utility.EqualsUtility; |
| 19 | import org.qedeq.kernel.se.base.module.Import; |
| 20 | import org.qedeq.kernel.se.base.module.Specification; |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * Module import. Every needed module must be referenced as an module import. |
| 25 | * |
| 26 | * @author Michael Meyling |
| 27 | */ |
| 28 | public class ImportVo implements Import { |
| 29 | |
| 30 | /** Label for the imported module. All references to that module must have this prefix. */ |
| 31 | private String label; |
| 32 | |
| 33 | /** Specification of imported module. Includes location information. */ |
| 34 | private Specification specification; |
| 35 | |
| 36 | /** |
| 37 | * Constructs a new import. |
| 38 | * |
| 39 | * @param label Label for this import. All references to that module must |
| 40 | * have this prefix. |
| 41 | * @param specification Import specification. Includes location information. |
| 42 | */ |
| 43 | public ImportVo(final String label, final SpecificationVo specification) { |
| 44 | this.label = label; |
| 45 | this.specification = specification; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Constructs an empty import. |
| 50 | */ |
| 51 | public ImportVo() { |
| 52 | // nothing to do |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Set label for this import module. All references to this module must have this |
| 57 | * prefix. |
| 58 | * |
| 59 | * @param label Prefix for this imported module. |
| 60 | */ |
| 61 | public final void setLabel(final String label) { |
| 62 | this.label = label; |
| 63 | } |
| 64 | |
| 65 | public final String getLabel() { |
| 66 | return label; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Set specification of this imported module. Contains location information. |
| 71 | * |
| 72 | * @param specification Module specification. |
| 73 | */ |
| 74 | public final void setSpecification(final SpecificationVo specification) { |
| 75 | this.specification = specification; |
| 76 | } |
| 77 | |
| 78 | public final Specification getSpecification() { |
| 79 | return specification; |
| 80 | } |
| 81 | |
| 82 | public boolean equals(final Object obj) { |
| 83 | if (!(obj instanceof ImportVo)) { |
| 84 | return false; |
| 85 | } |
| 86 | final ImportVo other = (ImportVo) obj; |
| 87 | return EqualsUtility.equals(getLabel(), other.getLabel()) |
| 88 | && EqualsUtility.equals(getSpecification(), other.getSpecification()); |
| 89 | } |
| 90 | |
| 91 | public int hashCode() { |
| 92 | return (getLabel() != null ? getLabel().hashCode() : 0) |
| 93 | ^ (getSpecification() != null ? 1 ^ getSpecification().hashCode() : 0); |
| 94 | } |
| 95 | |
| 96 | public String toString() { |
| 97 | return label + ":" + specification; |
| 98 | } |
| 99 | |
| 100 | } |