1
14
15 package com.liferay.portal.tools.servicebuilder;
16
17 import com.liferay.portal.kernel.util.Validator;
18 import com.liferay.util.TextFormatter;
19
20
26 public class EntityColumn implements Cloneable {
27
28 public EntityColumn(String name) {
29 this(
30 name, null, null, false, null, null, null, true, true, null, null,
31 null, true, false);
32 }
33
34 public EntityColumn(
35 String name, String dbName, String type, boolean primary,
36 String ejbName, String mappingKey, String mappingTable,
37 boolean caseSensitive, boolean orderByAscending, String comparator,
38 String idType, String idParam, boolean convertNull, boolean localized) {
39
40 _name = name;
41 _dbName = dbName;
42 _type = type;
43 _primary = primary;
44 _methodName = TextFormatter.format(name, TextFormatter.G);
45 _ejbName = ejbName;
46 _mappingKey = mappingKey;
47 _mappingTable = mappingTable;
48 _caseSensitive = caseSensitive;
49 _orderByAscending = orderByAscending;
50 _comparator = comparator;
51 _idType = idType;
52 _idParam = idParam;
53 _convertNull = convertNull;
54 _localized = localized;
55 }
56
57 public EntityColumn(
58 String name, String dbName, String type, boolean primary,
59 String ejbName, String mappingKey, String mappingTable, String idType,
60 String idParam, boolean convertNull, boolean localized) {
61
62 this(
63 name, dbName, type, primary, ejbName, mappingKey, mappingTable,
64 true, true, null, idType, idParam, convertNull, localized);
65 }
66
67 public Object clone() {
68 return new EntityColumn(
69 getName(), getDBName(), getType(), isPrimary(), getEJBName(),
70 getMappingKey(), getMappingTable(), isCaseSensitive(),
71 isOrderByAscending(), getComparator(), getIdType(), getIdParam(),
72 isConvertNull(), isLocalized());
73 }
74
75 public boolean equals(Object obj) {
76 EntityColumn col = (EntityColumn)obj;
77
78 String name = col.getName();
79
80 if (_name.equals(name)) {
81 return true;
82 }
83 else {
84 return false;
85 }
86 }
87
88 public String getComparator() {
89 return _comparator;
90 }
91
92 public String getDBName() {
93 return _dbName;
94 }
95
96 public String getEJBName() {
97 return _ejbName;
98 }
99
100 public String getIdParam() {
101 return _idParam;
102 }
103
104 public String getIdType() {
105 return _idType;
106 }
107
108 public String getMappingKey() {
109 return _mappingKey;
110 }
111
112 public String getMappingTable() {
113 return _mappingTable;
114 }
115
116 public String getMethodName() {
117 return _methodName;
118 }
119
120 public String getMethodNames() {
121 return TextFormatter.formatPlural(new String(_methodName));
122 }
123
124 public String getMethodUserUuidName() {
125 return _methodName.substring(0, _methodName.length() - 2) + "Uuid";
126 }
127
128 public String getName() {
129 return _name;
130 }
131
132 public String getNames() {
133 return TextFormatter.formatPlural(new String(_name));
134 }
135
136 public String getType() {
137 return _type;
138 }
139
140 public String getUserUuidName() {
141 return _name.substring(0, _name.length() - 2) + "Uuid";
142 }
143
144 public boolean isCaseSensitive() {
145 return _caseSensitive;
146 }
147
148 public boolean isCollection() {
149 if (_type.equals("Collection")) {
150 return true;
151 }
152 else {
153 return false;
154 }
155 }
156
157 public boolean isConvertNull() {
158 return _convertNull;
159 }
160
161 public boolean isFetchFinderPath() {
162 return _fetchFinderPath;
163 }
164
165 public boolean isLocalized() {
166 return _localized;
167 }
168
169 public boolean isMappingManyToMany() {
170 return Validator.isNotNull(_mappingTable);
171 }
172
173 public boolean isMappingOneToMany() {
174 return Validator.isNotNull(_mappingKey);
175 }
176
177 public boolean isOrderByAscending() {
178 return _orderByAscending;
179 }
180
181 public boolean isPrimary() {
182 return _primary;
183 }
184
185 public boolean isPrimitiveType() {
186 if (Character.isLowerCase(_type.charAt(0))) {
187 return true;
188 }
189 else {
190 return false;
191 }
192 }
193
194 public boolean isUserUuid() {
195 if (_type.equals("long") && _methodName.endsWith("UserId")) {
196 return true;
197 }
198 else {
199 return false;
200 }
201 }
202
203 public void setCaseSensitive(boolean caseSensitive) {
204 _caseSensitive = caseSensitive;
205 }
206
207 public void setComparator(String comparator) {
208 _comparator = comparator;
209 }
210
211 public void setConvertNull(boolean convertNull) {
212 _convertNull = convertNull;
213 }
214
215 public void setDBName(String dbName) {
216 _dbName = dbName;
217 }
218
219 public void setFetchFinderPath(boolean fetchFinderPath) {
220 _fetchFinderPath = fetchFinderPath;
221 }
222
223 public void setIdParam(String idParam) {
224 _idParam = idParam;
225 }
226
227 public void setIdType(String idType) {
228 _idType = idType;
229 }
230
231 public void setLocalized(boolean localized) {
232 _localized = localized;
233 }
234
235 public void setOrderByAscending(boolean orderByAscending) {
236 _orderByAscending = orderByAscending;
237 }
238
239 private boolean _caseSensitive;
240 private String _comparator;
241 private boolean _convertNull;
242 private String _dbName;
243 private String _ejbName;
244 private boolean _fetchFinderPath;
245 private String _idParam;
246 private String _idType;
247 private boolean _localized;
248 private String _mappingKey;
249 private String _mappingTable;
250 private String _methodName;
251 private String _name;
252 private boolean _orderByAscending;
253 private boolean _primary;
254 private String _type;
255
256 }