1 package org.simantics.modeling.ui.componentTypeEditor;
3 import org.simantics.databoard.annotations.Optional;
4 import org.simantics.databoard.type.NumberType;
5 import org.simantics.db.Resource;
6 import org.simantics.utils.strings.AlphanumComparator;
7 import org.simantics.utils.strings.StringUtils;
9 public class ComponentTypeViewerPropertyInfo implements Comparable<ComponentTypeViewerPropertyInfo> {
10 public Resource resource;
13 public String defaultValue;
15 public String description;
17 public String expression;
21 public NumberType numberType;
24 public boolean immutable;
25 public Object sectionSpecificData;
27 public ComponentTypeViewerPropertyInfo(Resource resource, String name, String type, String defaultValue, NumberType numberType, String unit, String label, String description, String expression, String valid, boolean immutable) {
28 this.resource = resource;
31 this.defaultValue = defaultValue;
32 this.numberType = numberType;
35 this.description = description;
36 this.expression = expression;
38 this.immutable = immutable;
42 public int compareTo(ComponentTypeViewerPropertyInfo o) {
43 return AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(name, (o.name));
47 public int hashCode() {
50 result = prime * result
51 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
52 result = prime * result
53 + ((description == null) ? 0 : description.hashCode());
54 result = prime * result
55 + ((expression == null) ? 0 : expression.hashCode());
56 result = prime * result + (immutable ? 1231 : 1237);
57 result = prime * result + ((label == null) ? 0 : label.hashCode());
58 result = prime * result + ((name == null) ? 0 : name.hashCode());
59 result = prime * result
60 + ((numberType == null) ? 0 : numberType.hashCode());
61 result = prime * result
62 + ((resource == null) ? 0 : resource.hashCode());
63 result = prime * result + ((sectionSpecificData == null) ? 0
64 : sectionSpecificData.hashCode());
65 result = prime * result + ((type == null) ? 0 : type.hashCode());
66 result = prime * result + ((unit == null) ? 0 : unit.hashCode());
67 result = prime * result + ((valid == null) ? 0 : valid.hashCode());
72 public boolean equals(Object obj) {
77 if (getClass() != obj.getClass())
79 ComponentTypeViewerPropertyInfo other = (ComponentTypeViewerPropertyInfo) obj;
80 if (defaultValue == null) {
81 if (other.defaultValue != null)
83 } else if (!defaultValue.equals(other.defaultValue))
85 if (description == null) {
86 if (other.description != null)
88 } else if (!description.equals(other.description))
90 if (expression == null) {
91 if (other.expression != null)
93 } else if (!expression.equals(other.expression))
95 if (immutable != other.immutable)
98 if (other.label != null)
100 } else if (!label.equals(other.label))
103 if (other.name != null)
105 } else if (!name.equals(other.name))
107 if (numberType == null) {
108 if (other.numberType != null)
110 } else if (!numberType.equals(other.numberType))
112 if (resource == null) {
113 if (other.resource != null)
115 } else if (!resource.equals(other.resource))
117 if (sectionSpecificData == null) {
118 if (other.sectionSpecificData != null)
120 } else if (!sectionSpecificData.equals(other.sectionSpecificData))
123 if (other.type != null)
125 } else if (!type.equals(other.type))
128 if (other.unit != null)
130 } else if (!unit.equals(other.unit))
133 if (other.valid != null)
135 } else if (!valid.equals(other.valid))
140 public String unitString() {
141 String result = numberType == null ? null : numberType.getUnit();
144 return StringUtils.safeString(result);
147 public String rangeString() {
148 return StringUtils.safeString(numberType == null ? null : numberType.getRangeStr());