com.jenkov.mrpersister.impl.mapping.method
Class MethodMapping

java.lang.Object
  extended by com.jenkov.mrpersister.impl.mapping.method.MethodMapping
All Implemented Interfaces:
IMethodMapping, java.lang.Comparable
Direct Known Subclasses:
GetterMapping, SetterMapping

public class MethodMapping
extends java.lang.Object
implements IMethodMapping, java.lang.Comparable


Field Summary
protected  java.lang.String columnName
           
protected  int columnType
           
protected  boolean isPrimaryKey
           
protected  boolean isTableMapped
           
protected  java.lang.reflect.Method objectMethod
           
 
Constructor Summary
MethodMapping()
           
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object o)
           
 java.lang.String getColumnName()
          Returns the database table column name this method method is method to.
 int getColumnType()
          Returns the column type as defined in the database.
 java.lang.reflect.Method getObjectMethod()
          Returns the method instance this method method is method from.
 int hashCode()
           
protected  boolean isNumberType()
           
 boolean isPrimaryKey()
          Returns true if the database column referenced by this method method is the primary key of the table it comes from.
protected  boolean isStringType()
           
 boolean isTableMapped()
          Returns true if the database column referenced by this method method exists in a table in the database.
 void setColumnName(java.lang.String fieldName)
          Sets the database column name this method method is method to.
 void setColumnType(int columnType)
          Sets the column type as defined in the database.
 void setObjectMethod(java.lang.reflect.Method member)
          The method instance this method method maps from.
 void setPrimaryKey(boolean isPrimaryKey)
          Sets whether or not the column referenced by this method method is the primary key.
 void setTableMapped(boolean isTableMapped)
          Sets whether or not the database column referenced by this method method exists in a table in the database.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

columnName

protected java.lang.String columnName

columnType

protected int columnType

objectMethod

protected java.lang.reflect.Method objectMethod

isPrimaryKey

protected boolean isPrimaryKey

isTableMapped

protected boolean isTableMapped
Constructor Detail

MethodMapping

public MethodMapping()
Method Detail

getColumnName

public java.lang.String getColumnName()
Description copied from interface: IMethodMapping
Returns the database table column name this method method is method to.

Specified by:
getColumnName in interface IMethodMapping
Returns:
The database table column name this method method is method to.

setColumnName

public void setColumnName(java.lang.String fieldName)
Description copied from interface: IMethodMapping
Sets the database column name this method method is method to.

Specified by:
setColumnName in interface IMethodMapping
Parameters:
fieldName - The column name to map to.

getColumnType

public int getColumnType()
Description copied from interface: IMethodMapping
Returns the column type as defined in the database. The int returned will match one of the java.sql.Types.XXX constants.

Specified by:
getColumnType in interface IMethodMapping
Returns:
The column type as defined in the database.

setColumnType

public void setColumnType(int columnType)
Description copied from interface: IMethodMapping
Sets the column type as defined in the database. The int should match one of the java.sql.Types.XXX constants.

Specified by:
setColumnType in interface IMethodMapping
Parameters:
columnType - The column type as defined in the database.

isNumberType

protected boolean isNumberType()

isStringType

protected boolean isStringType()

getObjectMethod

public java.lang.reflect.Method getObjectMethod()
Description copied from interface: IMethodMapping
Returns the method instance this method method is method from.

Specified by:
getObjectMethod in interface IMethodMapping
Returns:
The Method instance this method method is method from.

setObjectMethod

public void setObjectMethod(java.lang.reflect.Method member)
Description copied from interface: IMethodMapping
The method instance this method method maps from.

Specified by:
setObjectMethod in interface IMethodMapping
Parameters:
member - The Method instance this method method maps from.

isPrimaryKey

public boolean isPrimaryKey()
Description copied from interface: IMethodMapping
Returns true if the database column referenced by this method method is the primary key of the table it comes from.

Specified by:
isPrimaryKey in interface IMethodMapping
Returns:
True if the database column referenced by this method method is the primary key of the table it comes from. False if not.

setPrimaryKey

public void setPrimaryKey(boolean isPrimaryKey)
Description copied from interface: IMethodMapping
Sets whether or not the column referenced by this method method is the primary key.

Specified by:
setPrimaryKey in interface IMethodMapping
Parameters:
isPrimaryKey - Set to true if the column referenced by this method method is the primary key of the table it comes from.

isTableMapped

public boolean isTableMapped()
Description copied from interface: IMethodMapping
Returns true if the database column referenced by this method method exists in a table in the database. False if not. Objects can be mapped to SQL queries with arbitrary column names not existing in the database. For instance a setter method of an object can be mapped to the column name totalCount in the SQL query "select count(*) totalCount from employees

Specified by:
isTableMapped in interface IMethodMapping
Returns:
True if the database column referenced by this method method exists in a table in the database. False if not.

setTableMapped

public void setTableMapped(boolean isTableMapped)
Description copied from interface: IMethodMapping
Sets whether or not the database column referenced by this method method exists in a table in the database. Set to true if it does. False if not. Objects can be mapped to SQL queries with arbitrary column names not existing in the database. For instance a setter method of an object can be mapped to the column name totalCount in the SQL query "select count(*) totalCount from employees

Specified by:
setTableMapped in interface IMethodMapping

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable