Add MutableValueNext to replace mutableContent such that hash compute is only done once

Adds MutableValueInfo.nextDirty() to replace the isEqualToJson() method. The next is computed once and stored. BindablePropertyJsonUpdate makes the .mutableNext(propertyIndex) call to move the next MutableValueInfo and return the json content.
This commit is contained in:
rbygrave
2021-07-29 15:42:16 +12:00
parent 0d8e7c852b
commit c66d248e96
5 changed files with 125 additions and 47 deletions
@@ -12,12 +12,15 @@ package io.ebean.bean;
public interface MutableValueInfo {
/**
* Compares the given json to an internal value. Can be a hash/checksum comparison
* or a plain JSON string comparison (based on {@code @DbJson(keepSource)}).
* Compares the given json returning null if deemed unchanged or returning
* the MutableValueNext to use if deemed dirty/changed.
* <p>
* Returning MutableValueNext allows an implementation based on hash/checksum
* to only perform that computation once.
*
* @return true if the value is considered unchanged (when comparing in json form).
* @return Null if deemed unchanged or the MutableValueNext if deemed changed.
*/
boolean isEqualToJson(String json);
MutableValueNext nextDirty(String json);
/**
* Compares the given object to an internal value.