Skip to content
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

cadc-util-1.9.10: made Entity.isDataModelClass() protected #229

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
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
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
Loading