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 int hashCode() {
145 return _name.hashCode();
146 }
147
148 public boolean isCaseSensitive() {
149 return _caseSensitive;
150 }
151
152 public boolean isCollection() {
153 if (_type.equals("Collection")) {
154 return true;
155 }
156 else {
157 return false;
158 }
159 }
160
161 public boolean isConvertNull() {
162 return _convertNull;
163 }
164
165 public boolean isFetchFinderPath() {
166 return _fetchFinderPath;
167 }
168
169 public boolean isLocalized() {
170 return _localized;
171 }
172
173 public boolean isMappingManyToMany() {
174 return Validator.isNotNull(_mappingTable);
175 }
176
177 public boolean isMappingOneToMany() {
178 return Validator.isNotNull(_mappingKey);
179 }
180
181 public boolean isOrderByAscending() {
182 return _orderByAscending;
183 }
184
185 public boolean isPrimary() {
186 return _primary;
187 }
188
189 public boolean isPrimitiveType() {
190 if (Character.isLowerCase(_type.charAt(0))) {
191 return true;
192 }
193 else {
194 return false;
195 }
196 }
197
198 public boolean isUserUuid() {
199 if (_type.equals("long") && _methodName.endsWith("UserId")) {
200 return true;
201 }
202 else {
203 return false;
204 }
205 }
206
207 public void setCaseSensitive(boolean caseSensitive) {
208 _caseSensitive = caseSensitive;
209 }
210
211 public void setComparator(String comparator) {
212 _comparator = comparator;
213 }
214
215 public void setConvertNull(boolean convertNull) {
216 _convertNull = convertNull;
217 }
218
219 public void setDBName(String dbName) {
220 _dbName = dbName;
221 }
222
223 public void setFetchFinderPath(boolean fetchFinderPath) {
224 _fetchFinderPath = fetchFinderPath;
225 }
226
227 public void setIdParam(String idParam) {
228 _idParam = idParam;
229 }
230
231 public void setIdType(String idType) {
232 _idType = idType;
233 }
234
235 public void setLocalized(boolean localized) {
236 _localized = localized;
237 }
238
239 public void setOrderByAscending(boolean orderByAscending) {
240 _orderByAscending = orderByAscending;
241 }
242
243 private boolean _caseSensitive;
244 private String _comparator;
245 private boolean _convertNull;
246 private String _dbName;
247 private String _ejbName;
248 private boolean _fetchFinderPath;
249 private String _idParam;
250 private String _idType;
251 private boolean _localized;
252 private String _mappingKey;
253 private String _mappingTable;
254 private String _methodName;
255 private String _name;
256 private boolean _orderByAscending;
257 private boolean _primary;
258 private String _type;
259
260 }