View Javadoc

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  public class ParameterImpl implements Parameter {
23  
24      private String group;
25  
26      private String identifier;
27  
28      private String displayName;
29  
30      private String defaultValue;
31  
32      private boolean isEditable;
33  
34      private ValueType valueType;
35  
36      private int order;
37      
38      public ParameterImpl(
39              String group, 
40              String identifier, 
41              String displayName, 
42              String defaultValue, 
43              boolean isEditable,
44              ValueType valueType,
45              int order) {
46  
47          this.group = group;
48          this.identifier = identifier;
49          this.displayName = displayName;
50          this.defaultValue = defaultValue;
51          this.isEditable = isEditable;
52          this.valueType = valueType;
53          this.order = order;
54      }
55  
56      public String getGroup() {
57          return group;
58      }
59  
60      public String getIdentifier() {
61          return identifier;
62      }
63  
64      public String getDisplayName() {
65          return displayName;
66      }
67  
68      public String getDefaultValue() {
69          return defaultValue;
70      }
71  
72      public boolean valueIsEditable() {
73          return isEditable;
74      }
75  
76      public ValueType valueType() {
77          return valueType;
78      }
79  
80      public int getOrder() {
81          return order;
82      }
83  
84      // ------------------------- Object
85      
86      @Override
87      public String toString() {
88          return group + " : " + identifier + " : " + displayName;
89      }
90  
91      // ------------------------- Comparable
92  
93      public int compareTo(Parameter o) {
94          int result = -1;
95          
96          if (equals(o)) {
97              result = 0;
98          } else {
99              result = Integer.valueOf(getOrder()).compareTo(o.getOrder());
100             
101             // If equals is false but orderSign is equal, order by Identifier
102             if (result == 0) {
103                 result = -1;
104             }
105         }
106  
107         return result;
108     }
109 }