@Override
protected void parseFields() throws Exception {
for (Method m : getMethods(clazz)) {
DbPrimaryKey pk = m.getAnnotation(DbPrimaryKey.class);
DbPersistent p = m.getAnnotation(DbPersistent.class);
DbIndex idx = m.getAnnotation(DbIndex.class);
DbRelation r = m.getAnnotation(DbRelation.class);
// for ( Annotation a : m.getAnnotations()) {
// System.out.println(m.getName() + ": " + a.toString());
// }
if (pk != null || p != null || r != null ) {
String mName = m.getName();
Method getter = null;
Method setter = null;
if (mName.startsWith("get")) {
mName = mName.substring(3);
getter = m;
try {
setter = clazz.getMethod("set" + mName,getter.getReturnType());
} catch (NoSuchMethodException nsme) {}
} else
if (mName.startsWith("set")) {
mName = mName.substring(3);
setter = m;
try {
getter = clazz.getMethod("get" + mName);
} catch (NoSuchMethodException nsme) {
getter = clazz.getMethod("is" + mName);
}
} else
if (mName.startsWith("is")) {
mName = mName.substring(2);
getter = m;
setter = clazz.getMethod("set" + mName,getter.getReturnType());
} else {
log().d("field is not a getter/setter" + mName);
continue;
}
if (getter == null) {
log().d("getter not found",mName);
continue;
}
if (setter == null && r == null) { // relations do not need setters
log().d("setter not found",mName);
continue;
}
Class<?> ret = getter.getReturnType();
if (ret == void.class) {
log().d("Value type is void - ignore");
continue;
}
if (fIndex.containsKey(mName.toLowerCase())) {
log().d("field already defined", mName);
continue;
}
if (r != null) {
log().t("relation",mName);
// check for doubled
if (getFieldRelation(mName) != null || getField(mName) != null) {
log().t("double field definition", mName);
continue;
}
FieldRelation fr = new FieldRelation(manager, this, mName, setter, getter, ret, r);
addField(fr);
} else {
log().t("field",mName);
IConfig attr = MConfigFactory.getInstance().toConfig(toAttributes(p));
boolean v = (p !=null && p.virtual());
// check for doubled
if (getField(mName) != null || getFieldRelation(mName) != null) {
log().t("double field definition", mName);
continue;