mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
some javadoc and refactored getOrigValue
This commit is contained in:
@@ -470,6 +470,10 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
* Return the original value that was changed via an update.
|
||||
*/
|
||||
public Object getOrigValue(int propertyIndex) {
|
||||
if ((flags[propertyIndex] & (FLAG_ORIG_VALUE_SET | FLAG_MUTABLE_HASH_SET)) == FLAG_MUTABLE_HASH_SET) {
|
||||
// mutable hash set, but not ORIG_VALUE
|
||||
setOriginalValue(propertyIndex, mutableHash[propertyIndex].get());
|
||||
}
|
||||
if (origValues == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -718,11 +722,6 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
String propName = (prefix == null ? getProperty(i) : prefix + getProperty(i));
|
||||
Object newVal = owner._ebean_getField(i);
|
||||
Object oldVal = getOrigValue(i);
|
||||
if ((flags[i] & (FLAG_ORIG_VALUE_SET | FLAG_MUTABLE_HASH_SET)) == FLAG_MUTABLE_HASH_SET) {
|
||||
// mutable hash set, but not ORIG_VALUE
|
||||
oldVal = mutableHash[i].get();
|
||||
setOriginalValue(i, oldVal);
|
||||
}
|
||||
if (notEqual(oldVal, newVal)) {
|
||||
dirtyValues.put(propName, new ValuePair(newVal, oldVal));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
package io.ebean.bean;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to for mutable information in EntityBeanIntercept.
|
||||
*/
|
||||
public interface MutableHash {
|
||||
|
||||
/**
|
||||
* Compares the given json to an internal value. Can be a MD5 hash or a plain JSON string.
|
||||
* @return true if the value matches the hash.
|
||||
*/
|
||||
boolean isEqualToJson(String json);
|
||||
|
||||
/**
|
||||
* Compares the given object to an internal value. This is an optional method, but required for proper changelog/beanState support.
|
||||
* The implementation can serialize the object and compare it against the original json.
|
||||
*/
|
||||
default boolean isEqualToObject(Object obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance from the internal json string. This is an optional method.
|
||||
*/
|
||||
default Object get() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user