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.LocationList; |
20 | import org.qedeq.kernel.se.base.module.Specification; |
21 | |
22 | |
23 | /** |
24 | * Describes a specification of a module, that means its name, versions and possible |
25 | * "physical" locations. |
26 | * The combination of {@link #getName()} and {@link #getRuleVersion()} defines the |
27 | * file name of that module. |
28 | * |
29 | * @author Michael Meyling |
30 | */ |
31 | public class SpecificationVo implements Specification { |
32 | |
33 | /** Module name. */ |
34 | private String name; |
35 | |
36 | /** Rule version, that is needed to verify the module. */ |
37 | private String ruleVersion; |
38 | |
39 | /** List of locations for the module. */ |
40 | private LocationList locationList; |
41 | |
42 | /** |
43 | * Constructs a module specification. The combination of <code>name</code> and |
44 | * <code>ruleVersion</code> defines the file name of that module. |
45 | * |
46 | * @param name Module name. |
47 | * @param ruleVersion Rule version. This version is at least needed to verify that module. |
48 | * @param locations List of locations for that module. |
49 | */ |
50 | public SpecificationVo(final String name, final String ruleVersion, |
51 | final LocationList locations) { |
52 | this.name = name; |
53 | this.ruleVersion = ruleVersion; |
54 | this.locationList = locations; |
55 | } |
56 | |
57 | /** |
58 | * Constructs an empty module specification. |
59 | */ |
60 | public SpecificationVo() { |
61 | // nothing to do |
62 | } |
63 | |
64 | public final void setName(final String name) { |
65 | this.name = name; |
66 | } |
67 | |
68 | public final String getName() { |
69 | return name; |
70 | } |
71 | |
72 | public final void setRuleVersion(final String ruleVersion) { |
73 | this.ruleVersion = ruleVersion; |
74 | } |
75 | |
76 | public final String getRuleVersion() { |
77 | return ruleVersion; |
78 | } |
79 | |
80 | /** |
81 | * Set list of locations for the module. |
82 | * |
83 | * @param locations List of locations for that module. |
84 | */ |
85 | public final void setLocationList(final LocationListVo locations) { |
86 | this.locationList = locations; |
87 | } |
88 | |
89 | public final LocationList getLocationList() { |
90 | return locationList; |
91 | } |
92 | |
93 | public boolean equals(final Object obj) { |
94 | if (!(obj instanceof SpecificationVo)) { |
95 | return false; |
96 | } |
97 | final SpecificationVo other = (SpecificationVo) obj; |
98 | return EqualsUtility.equals(getName(), other.getName()) |
99 | && EqualsUtility.equals(getRuleVersion(), other.getRuleVersion()) |
100 | && EqualsUtility.equals(getLocationList(), other.getLocationList()); |
101 | } |
102 | |
103 | public int hashCode() { |
104 | return (getName() != null ? getName().hashCode() : 0) |
105 | ^ (getRuleVersion() != null ? 1 ^ getRuleVersion().hashCode() : 0) |
106 | ^ (getLocationList() != null ? 1 ^ getLocationList().hashCode() : 0); |
107 | } |
108 | |
109 | public String toString() { |
110 | return "Name: " + name + ", Rule Version: " + ruleVersion + "\n" + locationList; |
111 | } |
112 | |
113 | } |