Skip to content

Allowing for better mapping of accessor methods #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions src/main/java/io/jsondb/CollectionMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,14 @@ public CollectionMetaData(String collectionName, Class<?> clazz, String schemaVe
this.collectionLock = new ReentrantReadWriteLock();

//Populate the class metadata
List<Field[]> fields = new ArrayList<>();
Field[] startFields = clazz.getDeclaredFields();
int totalFields = startFields.length;
fields.add(startFields);
while (clazz.getSuperclass() != Object.class) {
clazz = clazz.getSuperclass();
Field[] toAdd = clazz.getDeclaredFields();
totalFields += toAdd.length;
fields.add(toAdd);
}
setupClassMetadata(clazz);

int x = 0;
Field[] fs = new Field[totalFields];
for (Field[] field : fields) {
for (Field value : field) {
fs[x] = value;
x++;
}
}
this.idAnnotatedFieldGetterMethod = getterMethodMap.get(idAnnotatedFieldName);
this.idAnnotatedFieldSetterMethod = setterMethodMap.get(idAnnotatedFieldName);
}

private void setupClassMetadata(final Class<?> clazz) {
Field[] fs = clazz.getDeclaredFields();
Method[] ms = clazz.getDeclaredMethods();
for (Field f : fs) {
String fieldName = f.getName();
Expand Down Expand Up @@ -119,8 +107,7 @@ public CollectionMetaData(String collectionName, Class<?> clazz, String schemaVe
}
}
}
this.idAnnotatedFieldGetterMethod = getterMethodMap.get(idAnnotatedFieldName);
this.idAnnotatedFieldSetterMethod = setterMethodMap.get(idAnnotatedFieldName);
if (clazz.getSuperclass() != Object.class) setupClassMetadata(clazz.getSuperclass());
}

protected ReentrantReadWriteLock getCollectionLock() {
Expand Down