1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.api.repository.context; |
17 | |
|
18 | |
import java.util.Collection; |
19 | |
import java.util.HashMap; |
20 | |
import java.util.Map; |
21 | |
|
22 | |
import javax.xml.bind.annotation.XmlAccessType; |
23 | |
import javax.xml.bind.annotation.XmlAccessorType; |
24 | |
import javax.xml.bind.annotation.XmlAnyElement; |
25 | |
import javax.xml.bind.annotation.XmlElement; |
26 | |
import javax.xml.bind.annotation.XmlRootElement; |
27 | |
import javax.xml.bind.annotation.XmlType; |
28 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
29 | |
|
30 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
31 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
32 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
33 | |
import org.kuali.rice.core.api.CoreConstants; |
34 | |
import org.kuali.rice.core.util.jaxb.MapStringStringAdapter; |
35 | |
import org.w3c.dom.Element; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@XmlRootElement(name = ContextSelectionCriteria.Constants.ROOT_ELEMENT_NAME) |
44 | |
@XmlAccessorType(XmlAccessType.NONE) |
45 | |
@XmlType(name = ContextSelectionCriteria.Constants.TYPE_NAME, propOrder = { |
46 | |
ContextSelectionCriteria.Elements.NAMESPACE_CODE, |
47 | |
ContextSelectionCriteria.Elements.NAME, |
48 | |
ContextSelectionCriteria.Elements.CONTEXT_QUALIFIERS, |
49 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
50 | |
}) |
51 | |
public final class ContextSelectionCriteria { |
52 | |
|
53 | |
@XmlElement(name = Elements.NAMESPACE_CODE, required = true) |
54 | |
private final String namespaceCode; |
55 | |
|
56 | |
@XmlElement(name = Elements.NAME, required = false) |
57 | |
private final String name; |
58 | |
|
59 | |
@XmlElement(name = Elements.CONTEXT_QUALIFIERS) |
60 | |
@XmlJavaTypeAdapter(value = MapStringStringAdapter.class) |
61 | |
private final Map<String, String> contextQualifiers; |
62 | |
|
63 | 0 | @SuppressWarnings("unused") |
64 | |
@XmlAnyElement |
65 | |
private final Collection<Element> _futureElements = null; |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
@SuppressWarnings("unused") |
71 | 0 | private ContextSelectionCriteria() { |
72 | 0 | this.namespaceCode = null; |
73 | 0 | this.name = null; |
74 | 0 | this.contextQualifiers = null; |
75 | 0 | } |
76 | |
|
77 | 0 | private ContextSelectionCriteria(String namespaceCode, String name, Map<String, String> contextQualifiers) { |
78 | 0 | this.namespaceCode = namespaceCode; |
79 | 0 | this.name = name; |
80 | 0 | this.contextQualifiers = new HashMap<String, String>(); |
81 | 0 | if (contextQualifiers != null) { |
82 | 0 | this.contextQualifiers.putAll(contextQualifiers); |
83 | |
} |
84 | 0 | } |
85 | |
|
86 | |
public static ContextSelectionCriteria newCriteria(String namespaceCode, String name, Map<String, String> contextQualifiers) { |
87 | 0 | return new ContextSelectionCriteria(namespaceCode, name, contextQualifiers); |
88 | |
} |
89 | |
|
90 | |
public static ContextSelectionCriteria newCriteria(String namespaceCode, Map<String, String> contextQualifiers) { |
91 | 0 | return newCriteria(namespaceCode, null, contextQualifiers); |
92 | |
} |
93 | |
|
94 | |
public static ContextSelectionCriteria newCriteria(Map<String, String> contextQualifiers) { |
95 | 0 | return newCriteria(null, contextQualifiers); |
96 | |
} |
97 | |
|
98 | |
public String getNamespaceCode() { |
99 | 0 | return this.namespaceCode; |
100 | |
} |
101 | |
|
102 | |
public String getName() { |
103 | 0 | return this.name; |
104 | |
} |
105 | |
|
106 | |
public Map<String, String> getContextQualifiers() { |
107 | 0 | return this.contextQualifiers; |
108 | |
} |
109 | |
|
110 | |
@Override |
111 | |
public int hashCode() { |
112 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
113 | |
} |
114 | |
|
115 | |
@Override |
116 | |
public boolean equals(Object obj) { |
117 | 0 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
118 | |
} |
119 | |
|
120 | |
@Override |
121 | |
public String toString() { |
122 | 0 | return ToStringBuilder.reflectionToString(this); |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | 0 | static class Constants { |
129 | |
final static String ROOT_ELEMENT_NAME = "contextSelectionCriteria"; |
130 | |
final static String TYPE_NAME = "ContextSelectionCriteriaType"; |
131 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS}; |
132 | |
} |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | 0 | static class Elements { |
139 | |
final static String NAMESPACE_CODE = "namespaceCode"; |
140 | |
final static String NAME = "name"; |
141 | |
final static String CONTEXT_QUALIFIERS = "contextQualifiers"; |
142 | |
} |
143 | |
|
144 | |
} |