If you think the Android project baracus-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package net.mantucon.baracus.orm;
/*fromwww.java2s.com*//**
* Created with IntelliJ IDEA.
* User: marcus
* Date: 24.09.12
* Time: 11:18
* <p/>
* indicate a field. notice, no type information is needed here, because of the
* use of rowmappers in the dao layer.
*/publicclass Field implements Comparable<Field> {
/**
* field index, increment by one per field, set default to AbstractModelBase.fieldList.size() , see AbstractModelBase example for details
*/publicfinalint fieldIndex;
/**
* the name of the field in the db
*/publicfinal String fieldName;
/**
* indicates a key attribute. normally - when deriving AbstractModelBase - you can use the constructor
* using fieldName and fieldIndex or just set it to false
*/publicfinalboolean isKeyAttribute;
/**
* Constructor for regular fields. Assumes, that your field is not part of the key.
*
* @param fieldName - db name of the field
* @param fieldIndex - the index of the field in the list
*/public Field(String fieldName, int fieldIndex) {
this.fieldName = fieldName;
this.fieldIndex = fieldIndex;
isKeyAttribute = false;
}
/**
* Constructor carrying a key information. normally the other constructor should fit your purpose.
*
* @param fieldName - db name of the field
* @param fieldIndex - the index of the field in the list
* @param isKeyAttribute - key attribute indicator
*/public Field(String fieldName, int fieldIndex, boolean isKeyAttribute) {
this.fieldName = fieldName;
this.fieldIndex = fieldIndex;
this.isKeyAttribute = isKeyAttribute;
}
@Override
publicfinal String toString() {
return fieldName;
}
@Override
publicboolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Field)) {
return false;
}
Field field = (Field) o;
if (fieldIndex != field.fieldIndex) {
return false;
}
if (fieldName != null ? !fieldName.equals(field.fieldName) : field.fieldName != null) {
return false;
}
return true;
}
@Override
publicint hashCode() {
int result = fieldIndex;
result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0);
return result;
}
@Override
publicint compareTo(Field field) {
return (Integer.valueOf(this.fieldIndex)).compareTo(Integer.valueOf(field.fieldIndex));
}
}