1 | |
package org.kuali.rice.core.api.uif.control; |
2 | |
|
3 | |
import javax.xml.bind.annotation.XmlAccessType; |
4 | |
import javax.xml.bind.annotation.XmlAccessorType; |
5 | |
import javax.xml.bind.annotation.XmlElement; |
6 | |
import javax.xml.bind.annotation.XmlType; |
7 | |
import java.util.ArrayList; |
8 | |
import java.util.Collection; |
9 | |
import java.util.Collections; |
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
@XmlAccessorType(XmlAccessType.NONE) |
15 | |
@XmlType(name = CheckboxGroup.Constants.TYPE_NAME) |
16 | 0 | public class CheckboxGroup extends AbstractControl implements CheckboxGroupContract { |
17 | |
@XmlElement(name = Elements.DEFAULT_VALUES, required = false) |
18 | |
private final Collection<String> defaultValues; |
19 | |
|
20 | |
@Override |
21 | |
public Collection<String> getDefaultValues() { |
22 | 0 | return Collections.unmodifiableCollection(defaultValues); |
23 | |
} |
24 | |
|
25 | 0 | private CheckboxGroup() { |
26 | 0 | defaultValues = null; |
27 | 0 | } |
28 | |
|
29 | |
private CheckboxGroup(Builder b) { |
30 | 0 | super(b); |
31 | 0 | defaultValues = b.defaultValues; |
32 | 0 | } |
33 | |
|
34 | 0 | public static final class Builder extends AbstractControl.Builder implements CheckboxGroupContract { |
35 | |
private Collection<String> defaultValues; |
36 | |
|
37 | |
private Builder(String name) { |
38 | 0 | super(name); |
39 | 0 | } |
40 | |
|
41 | |
public static Builder create(String name) { |
42 | 0 | return new Builder(name); |
43 | |
} |
44 | |
|
45 | |
public static Builder create(MultiSelectContract contract) { |
46 | 0 | Builder b = create(contract.getName()); |
47 | |
|
48 | 0 | partialCreate(contract, b); |
49 | |
|
50 | 0 | b.setDefaultValues(contract.getDefaultValues()); |
51 | 0 | return b; |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public Collection<String> getDefaultValues() { |
56 | 0 | return Collections.unmodifiableCollection(defaultValues); |
57 | |
} |
58 | |
|
59 | |
public void setDefaultValues(Collection<String> defaultValues) { |
60 | 0 | this.defaultValues = new ArrayList<String>(defaultValues); |
61 | 0 | } |
62 | |
|
63 | |
@Override |
64 | |
public CheckboxGroup build() { |
65 | 0 | return new CheckboxGroup(this); |
66 | |
} |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | 0 | static final class Constants { |
73 | |
static final String TYPE_NAME = "CheckboxGroupType"; |
74 | |
} |
75 | |
|
76 | 0 | static final class Elements { |
77 | |
static final String DEFAULT_VALUES = "defaultValues"; |
78 | |
} |
79 | |
} |