commit | author | age
|
c387eb
|
1 |
/* |
U |
2 |
* BaseLink - Generic object relational mapping |
|
3 |
* Copyright (C) 2011 Ulrich Hilger, http://uhilger.de |
|
4 |
* |
|
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
|
8 |
* (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program. If not, see http://www.gnu.org/licenses/ |
|
17 |
*/ |
|
18 |
|
|
19 |
package de.uhilger.baselink; |
|
20 |
|
|
21 |
import java.lang.reflect.Method; |
|
22 |
|
|
23 |
/** |
|
24 |
* Class <code>Field</code> represents a field in a database table. Objects of |
|
25 |
* class <code>Field</code> can be used to keep field name, field type, getter |
|
26 |
* and setter methods in one place for reference. |
|
27 |
* |
|
28 |
* @author Copyright (c) Ulrich Hilger, http://uhilger.de |
|
29 |
* @author Published under the terms and conditions of |
|
30 |
* the <a href="http://www.gnu.org/licenses/" target="_blank">GNU General Public License</a> |
|
31 |
*/ |
|
32 |
public class Field { |
|
33 |
|
|
34 |
private String columnName; |
|
35 |
private DBColumn.Type columnType; |
|
36 |
private Method getter; |
|
37 |
private Method setter; |
|
38 |
|
|
39 |
/** |
|
40 |
* Create a new object of class <code>Field</code> |
|
41 |
*/ |
|
42 |
public Field() { |
|
43 |
super(); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* Determine whether or not this object is equal to antoher object |
|
48 |
* @param obj the other object to compare with this object |
|
49 |
* @return true if this object is equal to the other object, false if not |
|
50 |
*/ |
|
51 |
@Override |
|
52 |
public boolean equals(Object obj) { |
|
53 |
boolean isEqual = false; |
|
54 |
if(obj != null && obj instanceof Field) { |
|
55 |
Field other = (Field) obj; |
|
56 |
isEqual = getColumnName().equals(other.getColumnName()); |
|
57 |
} |
|
58 |
return isEqual; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Get the column name of this field |
|
63 |
* @return the column name |
|
64 |
*/ |
|
65 |
public String getColumnName() { |
|
66 |
return columnName; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Set the column name of this field |
|
71 |
* @param columnName the column name |
|
72 |
*/ |
|
73 |
public void setColumnName(String columnName) { |
|
74 |
this.columnName = columnName; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Get the column type of this field |
|
79 |
* @return the column type |
|
80 |
*/ |
|
81 |
public DBColumn.Type getColumnType() { |
|
82 |
return columnType; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Set the column type of this field |
|
87 |
* @param columnType the column type |
|
88 |
*/ |
|
89 |
public void setColumnType(DBColumn.Type columnType) { |
|
90 |
this.columnType = columnType; |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Get the getter method for this field |
|
95 |
* @return the method to get the value of this field |
|
96 |
*/ |
|
97 |
public Method getGetter() { |
|
98 |
return getter; |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Set the getter method of this field |
|
103 |
* @param getter the method to get the value of this field |
|
104 |
*/ |
|
105 |
public void setGetter(Method getter) { |
|
106 |
this.getter = getter; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Get the setter method of this field |
10d5ad
|
111 |
* @return setter the method to set the value of this field |
c387eb
|
112 |
*/ |
U |
113 |
public Method getSetter() { |
|
114 |
return setter; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* Set the setter method of this field |
|
119 |
* @param setter the method to set the value of this field |
|
120 |
*/ |
|
121 |
public void setSetter(Method setter) { |
|
122 |
this.setter = setter; |
|
123 |
} |
|
124 |
|
|
125 |
|
|
126 |
} |