1 package org.lsst.ccs.config;
2
3
4 import org.hibernate.annotations.Immutable;
5
6 import javax.persistence.Embeddable;
7 import java.io.Serializable;
8
9
10
11
12
13 @Embeddable
14 @Immutable
15 public class ParameterPath implements PathObject , Serializable {
16 private static final long serialVersionUID = -1012785409109930223L;
17
18
19
20 /
21 componentName;
22
23
24
25 /
26 codeName ;
27
28
29
30 /
31 parameterName ;
32
33
34
35
36
37
38 ParameterPath() {
39 }
40
41
42
43
44
45
46
47 public ParameterPath(String componentName, String codeName, String parameterName) {
48 if(componentName == null || parameterName == null) {
49 throw new IllegalArgumentException("null argument in ParameterPath");
50 }
51 if(codeName == null) {
52 codeName = "" ;
53 }
54 this.componentName = componentName;
55 this.codeName = codeName;
56 this.parameterName = parameterName;
57 }
58
59
60
61 public String getComponentName() {
62 return componentName;
63 }
64
65 void setComponentName(String componentName) {
66 this.componentName = componentName;
67 }
68
69 public String getCodeName() {
70 return codeName;
71 }
72
73 void setCodeName(String codeName) {
74 this.codeName = codeName;
75 }
76
77 public String getParameterName() {
78 return parameterName;
79 }
80
81 void setParameterName(String parameterName) {
82 this.parameterName = parameterName;
83 }
84
85
86
87 @Override
88 public boolean equals(Object o) {
89 if (this == o) return true;
90 if (o == null || getClass() != o.getClass()) return false;
91
92 ParameterPath that = (ParameterPath) o;
93
94 if (codeName != null ? !codeName.equals(that.codeName) : that.codeName != null) return false;
95 if (!componentName.equals(that.componentName)) return false;
96 if (!parameterName.equals(that.parameterName)) return false;
97
98 return true;
99 }
100
101
102 @Override
103 public int hashCode() {
104 int result = componentName.hashCode();
105 result = 31 * result + (codeName != null ? codeName.hashCode() : 0);
106 result = 31 * result + parameterName.hashCode();
107 return result;
108 }
109
110 @Override
111 public String toString() {
112 String codeName = this.getCodeName() ;
113 if(codeName == null) {
114 codeName ="" ;
115 }
116 return this.componentName + '/'
117 + this.codeName + '/'
118 +this.parameterName ;
119 }
120
121
122
123
124
125
126
127 public static ParameterPath valueOf(String pathString) {
128 ParameterPath path ;
129 String[] elements = pathString.split("/") ;
130 if(elements.length != 3) {
131 throw new IllegalArgumentException("PathString should be componentName/codeName/parameterName");
132 }
133 path = new ParameterPath(elements[0], elements[1], elements[2]) ;
134 return path ;
135 }
136
137 @Override
138 public ParameterPath getPath() {
139 return this ;
140 }
141 }