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 = Textarea.Constants.TYPE_NAME) |
10 | 0 | public class Textarea extends AbstractControl implements TextareaContract { |
11 | |
|
12 | |
@XmlElement(name = Elements.ROWS, required = false) |
13 | |
private final Integer rows; |
14 | |
|
15 | |
@XmlElement(name = Elements.COLS, required = false) |
16 | |
private final Integer cols; |
17 | |
|
18 | |
@XmlElement(name = Elements.WATERMARK, required = false) |
19 | |
private final String watermark; |
20 | |
|
21 | |
@XmlElement(name = Elements.DEFAULT_VALUE, required = false) |
22 | |
private final String defaultValue; |
23 | |
|
24 | |
@Override |
25 | |
public Integer getRows() { |
26 | 0 | return rows; |
27 | |
} |
28 | |
|
29 | |
@Override |
30 | |
public Integer getCols() { |
31 | 0 | return cols; |
32 | |
} |
33 | |
|
34 | |
@Override |
35 | |
public String getWatermark() { |
36 | 0 | return watermark; |
37 | |
} |
38 | |
|
39 | |
@Override |
40 | |
public String getDefaultValue() { |
41 | 0 | return defaultValue; |
42 | |
} |
43 | |
|
44 | 0 | private Textarea() { |
45 | 0 | rows = null; |
46 | 0 | cols = null; |
47 | 0 | watermark = null; |
48 | 0 | defaultValue = null; |
49 | 0 | } |
50 | |
|
51 | |
private Textarea(Builder b) { |
52 | 0 | super(b); |
53 | 0 | rows = b.rows; |
54 | 0 | cols = b.cols; |
55 | 0 | watermark = b.watermark; |
56 | 0 | defaultValue = b.defaultValue; |
57 | 0 | } |
58 | |
|
59 | 0 | public static final class Builder extends AbstractControl.Builder implements TextareaContract { |
60 | |
private Integer rows; |
61 | |
private Integer cols; |
62 | |
private String watermark; |
63 | |
private String defaultValue; |
64 | |
|
65 | |
private Builder(String name) { |
66 | 0 | super(name); |
67 | 0 | } |
68 | |
|
69 | |
public static Builder create(String name) { |
70 | 0 | return new Builder(name); |
71 | |
} |
72 | |
|
73 | |
public static Builder create(TextareaContract contract) { |
74 | 0 | Builder b = create(contract.getName()); |
75 | |
|
76 | 0 | partialCreate(contract, b); |
77 | |
|
78 | 0 | b.setCols(contract.getCols()); |
79 | 0 | b.setRows(contract.getRows()); |
80 | 0 | b.setWatermark(contract.getWatermark()); |
81 | 0 | b.setDefaultValue(contract.getDefaultValue()); |
82 | 0 | return b; |
83 | |
} |
84 | |
|
85 | |
@Override |
86 | |
public Integer getRows() { |
87 | 0 | return rows; |
88 | |
} |
89 | |
|
90 | |
public void setRows(Integer rows) { |
91 | 0 | if (rows != null && rows < 1) { |
92 | 0 | throw new IllegalArgumentException("rows was < 1"); |
93 | |
} |
94 | |
|
95 | 0 | this.rows = rows; |
96 | 0 | } |
97 | |
|
98 | |
@Override |
99 | |
public Integer getCols() { |
100 | 0 | return cols; |
101 | |
} |
102 | |
|
103 | |
public void setCols(Integer cols) { |
104 | 0 | if (cols != null && cols < 1) { |
105 | 0 | throw new IllegalArgumentException("cols was < 1"); |
106 | |
} |
107 | |
|
108 | 0 | this.cols = cols; |
109 | 0 | } |
110 | |
|
111 | |
@Override |
112 | |
public String getWatermark() { |
113 | 0 | return watermark; |
114 | |
} |
115 | |
|
116 | |
public void setWatermark(String watermark) { |
117 | 0 | this.watermark = watermark; |
118 | 0 | } |
119 | |
|
120 | |
@Override |
121 | |
public String getDefaultValue() { |
122 | 0 | return defaultValue; |
123 | |
} |
124 | |
|
125 | |
public void setDefaultValue(String defaultValue) { |
126 | 0 | this.defaultValue = defaultValue; |
127 | 0 | } |
128 | |
|
129 | |
@Override |
130 | |
public Textarea build() { |
131 | 0 | return new Textarea(this); |
132 | |
} |
133 | |
} |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | 0 | static final class Constants { |
139 | |
static final String TYPE_NAME = "TextareaType"; |
140 | |
} |
141 | |
|
142 | 0 | static final class Elements { |
143 | |
static final String COLS = "cols"; |
144 | |
static final String ROWS = "rows"; |
145 | |
static final String WATERMARK = "watermark"; |
146 | |
static final String DEFAULT_VALUE = "defaultValue"; |
147 | |
} |
148 | |
} |