1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.api.uif; |
17 | |
|
18 | |
import org.kuali.rice.core.api.CoreConstants; |
19 | |
import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter; |
20 | |
import org.w3c.dom.Element; |
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 | |
import java.util.Collection; |
30 | |
import java.util.Collections; |
31 | |
import java.util.HashMap; |
32 | |
import java.util.Map; |
33 | |
import java.util.SortedMap; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
@XmlRootElement(name = RemotableRadioButtonGroup.Constants.ROOT_ELEMENT_NAME) |
39 | |
@XmlAccessorType(XmlAccessType.NONE) |
40 | |
@XmlType(name = RemotableRadioButtonGroup.Constants.TYPE_NAME, propOrder = { |
41 | |
RemotableRadioButtonGroup.Elements.KEY_LABELS, |
42 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS }) |
43 | 3 | public final class RemotableRadioButtonGroup extends RemotableAbstractControl implements KeyLabeled { |
44 | |
|
45 | |
@XmlElement(name = Elements.KEY_LABELS, required = true) |
46 | |
@XmlJavaTypeAdapter(value = MapStringStringAdapter.class) |
47 | |
private final Map<String, String> keyLabels; |
48 | |
|
49 | 5 | @SuppressWarnings("unused") |
50 | |
@XmlAnyElement |
51 | |
private final Collection<Element> _futureElements = null; |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
@SuppressWarnings("unused") |
57 | 2 | private RemotableRadioButtonGroup() { |
58 | 2 | keyLabels = null; |
59 | 2 | } |
60 | |
|
61 | 3 | private RemotableRadioButtonGroup(Builder b) { |
62 | 3 | keyLabels = b.keyLabels; |
63 | 3 | } |
64 | |
|
65 | |
@Override |
66 | |
public Map<String, String> getKeyLabels() { |
67 | 0 | return keyLabels; |
68 | |
} |
69 | |
|
70 | 6 | public static final class Builder extends RemotableAbstractControl.Builder implements KeyLabeled { |
71 | |
private Map<String, String> keyLabels; |
72 | |
|
73 | 5 | private Builder(Map<String, String> keyLabels) { |
74 | 5 | setKeyLabels(keyLabels); |
75 | 3 | } |
76 | |
|
77 | |
public static Builder create(Map<String, String> keyLabels) { |
78 | 5 | return new Builder(keyLabels); |
79 | |
} |
80 | |
|
81 | |
@Override |
82 | |
public Map<String, String> getKeyLabels() { |
83 | 0 | return keyLabels; |
84 | |
} |
85 | |
|
86 | |
public void setKeyLabels(Map<String, String> keyLabels) { |
87 | 5 | if (keyLabels == null || keyLabels.isEmpty()) { |
88 | 2 | throw new IllegalArgumentException("keyLabels must be non-null & non-empty"); |
89 | |
} |
90 | |
|
91 | 3 | if (keyLabels instanceof SortedMap) { |
92 | 0 | this.keyLabels = Collections.unmodifiableSortedMap((SortedMap)keyLabels); |
93 | |
} else { |
94 | 3 | this.keyLabels = Collections.unmodifiableMap(new HashMap<String, String>(keyLabels)); |
95 | |
} |
96 | 3 | } |
97 | |
|
98 | |
@Override |
99 | |
public RemotableRadioButtonGroup build() { |
100 | 3 | return new RemotableRadioButtonGroup(this); |
101 | |
} |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | 0 | static final class Constants { |
108 | |
static final String TYPE_NAME = "RadioButtonGroupType"; |
109 | |
final static String ROOT_ELEMENT_NAME = "radioButtonGroup"; |
110 | |
} |
111 | |
|
112 | 0 | static final class Elements { |
113 | |
static final String KEY_LABELS = "keyLabels"; |
114 | |
} |
115 | |
} |