1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.api.parameter;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreConstants;
20 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
21 import org.w3c.dom.Element;
22
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAnyElement;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29 import java.util.Collection;
30
31
32
33
34
35
36
37 @XmlRootElement(name = ParameterKey.Constants.ROOT_ELEMENT_NAME)
38 @XmlAccessorType(XmlAccessType.NONE)
39 @XmlType(name = ParameterKey.Constants.TYPE_NAME, propOrder = {
40 ParameterKey.Elements.APPLICATION_ID,
41 ParameterKey.Elements.NAMESPACE_CODE,
42 ParameterKey.Elements.COMPONENT_CODE,
43 ParameterKey.Elements.NAME,
44 CoreConstants.CommonElements.FUTURE_ELEMENTS
45 })
46 public final class ParameterKey extends AbstractDataTransferObject {
47
48 private static final long serialVersionUID = -4405355319548951283L;
49
50 @XmlElement(name = Elements.APPLICATION_ID, required=true)
51 private final String applicationId;
52
53 @XmlElement(name = Elements.NAMESPACE_CODE, required=true)
54 private final String namespaceCode;
55
56 @XmlElement(name = Elements.COMPONENT_CODE, required=true)
57 private final String componentCode;
58
59 @XmlElement(name = Elements.NAME, required=true)
60 private final String name;
61
62 @SuppressWarnings("unused")
63 @XmlAnyElement
64 private final Collection<Element> _futureElements = null;
65
66
67
68
69 private ParameterKey() {
70 this.applicationId = null;
71 this.namespaceCode = null;
72 this.componentCode = null;
73 this.name = null;
74 }
75
76
77
78
79 private ParameterKey(String applicationId, String namespaceCode, String componentCode, String name) {
80 if (StringUtils.isBlank(applicationId)) {
81 throw new IllegalArgumentException("applicationId is blank");
82 }
83 if (StringUtils.isBlank(namespaceCode)) {
84 throw new IllegalArgumentException("namespaceCode is blank");
85 }
86 if (StringUtils.isBlank(componentCode)) {
87 throw new IllegalArgumentException("componentCode is blank");
88 }
89 if (StringUtils.isBlank(name)) {
90 throw new IllegalArgumentException("name is blank");
91 }
92 this.applicationId = applicationId;
93 this.namespaceCode = namespaceCode;
94 this.componentCode = componentCode;
95 this.name = name;
96 }
97
98
99
100
101
102
103
104
105
106
107
108 public static ParameterKey create(String applicationId, String namespaceCode, String componentCode, String name) {
109 return new ParameterKey(applicationId, namespaceCode, componentCode, name);
110 }
111
112 public String getApplicationId() {
113 return applicationId;
114 }
115
116 public String getNamespaceCode() {
117 return namespaceCode;
118 }
119
120 public String getComponentCode() {
121 return componentCode;
122 }
123
124 public String getName() {
125 return name;
126 }
127
128 public String getCacheKey() {
129 return this.applicationId + ":" + this.namespaceCode + ":" + this.componentCode + ":" + this.name;
130 }
131
132
133
134
135 static class Constants {
136 final static String ROOT_ELEMENT_NAME = "parameterKey";
137 final static String TYPE_NAME = "ParameterKeyType";
138 }
139
140
141
142
143
144 static class Elements {
145 final static String APPLICATION_ID = "applicationId";
146 final static String NAMESPACE_CODE = "namespaceCode";
147 final static String COMPONENT_CODE = "componentCode";
148 final static String NAME = "name";
149 }
150
151 }