Skip to content

Commit

Permalink
cadc-util-1.9.10: made Entity.isDataModelClass() protected
Browse files Browse the repository at this point in the history
this is to support libraries that import specific data model classes and might need their own logic
  • Loading branch information
pdowler committed Sep 5, 2023
1 parent d390b3b commit 85a50f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cadc-util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.9.9'
version = '1.9.10'

description = 'OpenCADC core utility library'
def git_url = 'https://github.com/opencadc/core'
Expand Down
17 changes: 14 additions & 3 deletions cadc-util/src/main/java/org/opencadc/persist/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected void calcMetaChecksum(Class c, Object o, MessageDigest digest) {
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
throw new RuntimeException("BUG - enum " + ac.getName() + " does not have getValue()", ex);
}
} else if (isLocalClass(ac)) {
} else if (isDataModelClass(ac)) {
// depth-first recursion
calcMetaChecksum(ac, fo, digest);
} else if (fo instanceof Collection) {
Expand All @@ -290,7 +290,7 @@ protected void calcMetaChecksum(Class c, Object o, MessageDigest digest) {
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
throw new RuntimeException("BUG", ex);
}
} else if (isLocalClass(cc)) {
} else if (isDataModelClass(cc)) {
// depth-first recursion
calcMetaChecksum(cc, co, digest);
} else {
Expand All @@ -310,7 +310,18 @@ protected void calcMetaChecksum(Class c, Object o, MessageDigest digest) {
}
}

private boolean isLocalClass(Class c) {
/**
* Determine if the argument type is part of a data model implementation
* so reflection can be used to drill down into the structure. The standard
* implementation checks that the class is in the same package or a subpackage
* of the entity implementation. Subclasses can override this method and return
* true for classes that are outside their package (imported data model classes)
* and must otherwise call this method to return the standard value.
*
* @param c
* @return true if the class is a data model class, otherwise false
*/
protected boolean isDataModelClass(Class c) {
if (c.isPrimitive() || c.isArray()) {
return false;
}
Expand Down

0 comments on commit 85a50f0

Please sign in to comment.