1 /**
2 * Copyright (C) 2007 Joern Krueger surething@users.sourceforge.net
3 *
4 * This program is free software; you can redistribute
5 * it and/or modify it under the terms of the GNU General
6 * Public License version 2 as published by the Free Software
7 * Foundation.
8 *
9 * This program is distributed in the hope that it will be
10 * useful, but WITHOUT ANY WARRANTY; without even the implied
11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place,
18 * Suite 330, Boston, MA 02111-1307 USA
19 */
20 package de.surethingies.properties;
21
22 /**
23 * Stores a Value, identified by identifier for Parameter parameter
24 *
25 * @author krueger
26 */
27 public class TypedParameter implements Comparable<TypedParameter> {
28
29 private Parameter parameter;
30
31 private String identifier;
32
33 private String value;
34
35 public TypedParameter(Parameter parameter, String identifier, String value) {
36 this.parameter = parameter;
37 this.identifier = identifier;
38 this.value = value;
39 }
40
41 /**
42 * @return get the Group for this Parameter
43 */
44 public String getGroup() {
45 return parameter.getGroup();
46 }
47
48 /**
49 * @return get the managed Parameter
50 */
51 public Parameter getParameter() {
52 return parameter;
53 }
54
55 /**
56 * @return the unique Identifier for this Parameter
57 */
58 public String getIdentifier() {
59 return identifier;
60 }
61
62 /**
63 * @return get the current Value
64 */
65 public String getValue() {
66 return value;
67 }
68
69 /**
70 * Set the Value of the TypedParameter
71 *
72 * @param value
73 */
74 public void setValue(String value) {
75 this.value = value;
76 }
77
78
79
80 @Override
81 public String toString() {
82 return parameter + " : " + identifier + " : " + value;
83 }
84
85 @Override
86 public boolean equals(Object o) {
87 return (o instanceof TypedParameter
88 && ((TypedParameter) o).parameter.equals(parameter)
89 && ((TypedParameter) o).identifier.equals(identifier));
90 }
91
92 @Override
93 public int hashCode() {
94 return parameter.hashCode() * identifier.hashCode() * 17;
95 }
96
97
98 public int compareTo(TypedParameter o) {
99 int result = -1;
100
101 if (equals(o)) {
102 result = 0;
103 } else {
104 result = Integer.valueOf(parameter.getOrder()).compareTo(o.getParameter().getOrder());
105
106
107 if (result == 0) {
108 result = -1;
109 }
110 }
111
112 return result;
113 }
114 }