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.LinkedHashMap;
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  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      @SuppressWarnings("unused")
50      @XmlAnyElement
51      private final Collection<Element> _futureElements = null;
52  
53      
54  
55  
56      @SuppressWarnings("unused")
57      private RemotableRadioButtonGroup() {
58          keyLabels = null;
59      }
60  
61      private RemotableRadioButtonGroup(Builder b) {
62          keyLabels = b.keyLabels;
63      }
64  
65      @Override
66      public Map<String, String> getKeyLabels() {
67          return keyLabels;
68      }
69  
70      public static final class Builder extends RemotableAbstractControl.Builder implements KeyLabeled {
71          private Map<String, String> keyLabels;
72  
73          private Builder(Map<String, String> keyLabels) {
74              setKeyLabels(keyLabels);
75          }
76  
77          public static Builder create(Map<String, String> keyLabels) {
78              return new Builder(keyLabels);
79          }
80  
81          @Override
82          public Map<String, String> getKeyLabels() {
83              return keyLabels;
84          }
85  
86          public void setKeyLabels(Map<String, String> keyLabels) {
87              if (keyLabels == null || keyLabels.isEmpty()) {
88                  throw new IllegalArgumentException("keyLabels must be non-null & non-empty");
89              }
90              
91              if (keyLabels instanceof SortedMap) {
92                  this.keyLabels = Collections.unmodifiableSortedMap((SortedMap)keyLabels);
93              } else {
94                  this.keyLabels = Collections.unmodifiableMap(new LinkedHashMap<String, String>(keyLabels));
95              }
96          }
97  
98          @Override
99          public RemotableRadioButtonGroup build() {
100             return new RemotableRadioButtonGroup(this);
101         }
102     }
103 
104     
105 
106 
107     static final class Constants {
108         static final String TYPE_NAME = "RadioButtonGroupType";
109         final static String ROOT_ELEMENT_NAME = "radioButtonGroup";
110     }
111 
112     static final class Elements {
113         static final String KEY_LABELS = "keyLabels";
114     }
115 }