/*
* BaseLink - Generic object relational mapping
* Copyright (C) 2011 Ulrich Hilger, http://uhilger.de
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
*/
package de.uhilger.baselink;
import java.lang.reflect.Method;
/**
* Class Field
represents a field in a database table. Objects of
* class Field
can be used to keep field name, field type, getter
* and setter methods in one place for reference.
*
* @author Copyright (c) Ulrich Hilger, http://uhilger.de
* @author Published under the terms and conditions of
* the GNU General Public License
*/
public class Field {
private String columnName;
private DBColumn.Type columnType;
private Method getter;
private Method setter;
/**
* Create a new object of class Field
*/
public Field() {
super();
}
/**
* Determine whether or not this object is equal to antoher object
* @param obj the other object to compare with this object
* @return true if this object is equal to the other object, false if not
*/
@Override
public boolean equals(Object obj) {
boolean isEqual = false;
if(obj != null && obj instanceof Field) {
Field other = (Field) obj;
isEqual = getColumnName().equals(other.getColumnName());
}
return isEqual;
}
/**
* Get the column name of this field
* @return the column name
*/
public String getColumnName() {
return columnName;
}
/**
* Set the column name of this field
* @param columnName the column name
*/
public void setColumnName(String columnName) {
this.columnName = columnName;
}
/**
* Get the column type of this field
* @return the column type
*/
public DBColumn.Type getColumnType() {
return columnType;
}
/**
* Set the column type of this field
* @param columnType the column type
*/
public void setColumnType(DBColumn.Type columnType) {
this.columnType = columnType;
}
/**
* Get the getter method for this field
* @return the method to get the value of this field
*/
public Method getGetter() {
return getter;
}
/**
* Set the getter method of this field
* @param getter the method to get the value of this field
*/
public void setGetter(Method getter) {
this.getter = getter;
}
/**
* Get the setter method of this field
* @return setter the method to set the value of this field
*/
public Method getSetter() {
return setter;
}
/**
* Set the setter method of this field
* @param setter the method to set the value of this field
*/
public void setSetter(Method setter) {
this.setter = setter;
}
}