Rev 56 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | soliveira | 1 | /* |
22 | soliveira | 2 | * This program is free software: you can redistribute it and/or modify |
3 | * it under the terms of the GNU General Public License as published by |
||
4 | * the Free Software Foundation, either version 3 of the License, or |
||
5 | * (at your option) any later version. |
||
2 | soliveira | 6 | * |
22 | soliveira | 7 | * This program is distributed in the hope that it will be useful, |
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
10 | * GNU General Public License for more details. |
||
2 | soliveira | 11 | * |
22 | soliveira | 12 | * You should have received a copy of the GNU General Public License |
13 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
2 | soliveira | 14 | * |
22 | soliveira | 15 | * MentaBean => http://www.mentabean.org |
16 | * Author: Sergio Oliveira Jr. (sergio.oliveira.jr@gmail.com) |
||
2 | soliveira | 17 | */ |
18 | package org.mentabean; |
||
19 | |||
44 | soliveira | 20 | |
8 | soliveira | 21 | /** |
22 | soliveira | 22 | * A class representing a database field. It has the name of the bean property, the name of the column in the database, the database type, whether it is a PK or not and whether it default to now. |
8 | soliveira | 23 | * |
24 | * @author sergio.oliveira.jr@gmail.com |
||
25 | */ |
||
2 | soliveira | 26 | public class DBField { |
27 | |||
28 | private final String name; |
||
11 | soliveira | 29 | private final DBType<?> type; |
2 | soliveira | 30 | private final String dbName; |
31 | private final boolean isPK; |
||
32 | |||
11 | soliveira | 33 | public DBField(final String name, final String dbName, final DBType<?> type, final boolean isPK) { |
2 | soliveira | 34 | this.name = name; |
35 | this.dbName = dbName; |
||
36 | this.type = type; |
||
37 | this.isPK = isPK; |
||
38 | } |
||
39 | |||
40 | @Override |
||
41 | public String toString() { |
||
42 | |||
43 | final StringBuilder sb = new StringBuilder(32); |
||
44 | |||
45 | sb.append("DBField: ").append(name).append(" type=").append(type).append(" dbName=").append(dbName); |
||
46 | |||
47 | return sb.toString(); |
||
48 | } |
||
49 | |||
50 | @Override |
||
51 | public int hashCode() { |
||
52 | |||
53 | return name.hashCode(); |
||
54 | } |
||
55 | |||
56 | @Override |
||
57 | public boolean equals(final Object obj) { |
||
58 | |||
59 | if (obj instanceof DBField) { |
||
60 | |||
61 | final DBField f = (DBField) obj; |
||
62 | |||
63 | if (f.name.equalsIgnoreCase(this.name)) { |
||
64 | return true; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | return false; |
||
69 | } |
||
70 | |||
71 | public String getName() { |
||
72 | |||
73 | return name; |
||
74 | |||
75 | } |
||
76 | |||
219 | erico | 77 | @SuppressWarnings("rawtypes") |
2 | soliveira | 78 | public DBType getType() { |
79 | |||
80 | return type; |
||
81 | } |
||
82 | |||
83 | public String getDbName() { |
||
84 | |||
85 | return dbName; |
||
86 | } |
||
87 | |||
88 | public boolean isPK() { |
||
89 | |||
90 | return isPK; |
||
91 | } |
||
92 | |||
93 | } |