JSON bean dirty detection via MD5 of JSON string content

- MD5 of json content stored on EntityBeanIntercept for dirty detection
- Only convert to JSON once (at dirty detection time). Store this json content on EntityBeanIntercept to later push to ScalarTypeJsonObjectMapper for bind

Should consider alternative to extend BeanProperty rather than have these if blocks.
This commit is contained in:
rbygrave
2021-07-23 16:50:24 +12:00
parent f32ace4e5a
commit 6c262f1df5
19 changed files with 404 additions and 34 deletions
@@ -91,6 +91,17 @@ public final class EntityBeanIntercept implements Serializable {
private Object ownerId;
private int sortOrder;
/**
* Holds MD5 hash of json loaded jackson beans.
*/
private String[] mutableHash;
/**
* Holds json content determined at point of dirty check.
* Stored here on dirty check such that we only convert to json once.
*/
private String[] mutableContent;
/**
* Create a intercept with a given entity.
*/
@@ -1138,4 +1149,26 @@ public final class EntityBeanIntercept implements Serializable {
}
return ret;
}
public String mutableHash(int propertyIndex) {
return mutableHash == null ? null : mutableHash[propertyIndex];
}
public void mutableHash(int propertyIndex, String content) {
if (mutableHash == null) {
mutableHash = new String[flags.length];
}
mutableHash[propertyIndex] = content;
}
public String mutableContent(int propertyIndex) {
return mutableContent == null ? null : mutableContent[propertyIndex];
}
public void mutableContent(int propertyIndex, String content) {
if (mutableContent == null) {
mutableContent = new String[flags.length];
}
mutableContent[propertyIndex] = content;
}
}