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 | |
|
8 | |
@XmlAccessorType(XmlAccessType.NONE) |
9 | |
@XmlType(name = TextInput.Constants.TYPE_NAME) |
10 | 0 | public class TextInput extends AbstractControl implements TextInputContract { |
11 | |
|
12 | |
@XmlElement(name = Elements.SIZE, required = false) |
13 | |
private final Integer size; |
14 | |
|
15 | |
@XmlElement(name = Elements.WATERMARK, required = false) |
16 | |
private final String watermark; |
17 | |
|
18 | |
@XmlElement(name = Elements.DEFAULT_VALUE, required = false) |
19 | |
private final String defaultValue; |
20 | |
|
21 | |
@Override |
22 | |
public Integer getSize() { |
23 | 0 | return size; |
24 | |
} |
25 | |
|
26 | |
@Override |
27 | |
public String getWatermark() { |
28 | 0 | return watermark; |
29 | |
} |
30 | |
|
31 | |
@Override |
32 | |
public String getDefaultValue() { |
33 | 0 | return defaultValue; |
34 | |
} |
35 | |
|
36 | 0 | private TextInput() { |
37 | 0 | size = null; |
38 | 0 | watermark = null; |
39 | 0 | defaultValue = null; |
40 | 0 | } |
41 | |
|
42 | |
private TextInput(Builder b) { |
43 | 0 | super(b); |
44 | 0 | size = b.size; |
45 | 0 | watermark = b.watermark; |
46 | 0 | defaultValue = b.defaultValue; |
47 | 0 | } |
48 | |
|
49 | 0 | public static final class Builder extends AbstractControl.Builder implements TextInputContract { |
50 | |
private Integer size; |
51 | |
private String watermark; |
52 | |
private String defaultValue; |
53 | |
|
54 | |
private Builder(String name) { |
55 | 0 | super(name); |
56 | 0 | } |
57 | |
|
58 | |
public static Builder create(String name) { |
59 | 0 | return new Builder(name); |
60 | |
} |
61 | |
|
62 | |
public static Builder create(TextInputContract contract) { |
63 | 0 | Builder b = create(contract.getName()); |
64 | |
|
65 | 0 | partialCreate(contract, b); |
66 | |
|
67 | 0 | b.setSize(contract.getSize()); |
68 | 0 | b.setWatermark(contract.getWatermark()); |
69 | 0 | b.setDefaultValue(contract.getDefaultValue()); |
70 | 0 | return b; |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public Integer getSize() { |
75 | 0 | return size; |
76 | |
} |
77 | |
|
78 | |
public void setSize(Integer size) { |
79 | 0 | if (size != null && size < 1) { |
80 | 0 | throw new IllegalArgumentException("size was < 1"); |
81 | |
} |
82 | |
|
83 | 0 | this.size = size; |
84 | 0 | } |
85 | |
|
86 | |
@Override |
87 | |
public String getWatermark() { |
88 | 0 | return watermark; |
89 | |
} |
90 | |
|
91 | |
public void setWatermark(String watermark) { |
92 | 0 | this.watermark = watermark; |
93 | 0 | } |
94 | |
|
95 | |
|
96 | |
@Override |
97 | |
public String getDefaultValue() { |
98 | 0 | return defaultValue; |
99 | |
} |
100 | |
|
101 | |
public void setDefaultValue(String defaultValue) { |
102 | 0 | this.defaultValue = defaultValue; |
103 | 0 | } |
104 | |
|
105 | |
@Override |
106 | |
public TextInput build() { |
107 | 0 | return new TextInput(this); |
108 | |
} |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | 0 | static final class Constants { |
115 | |
static final String TYPE_NAME = "TextInputType"; |
116 | |
} |
117 | |
|
118 | 0 | static final class Elements { |
119 | |
static final String SIZE = "size"; |
120 | |
static final String WATERMARK = "watermark"; |
121 | |
static final String DEFAULT_VALUE = "defaultValue"; |
122 | |
} |
123 | |
} |