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