mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
some javadoc and refactored getOrigValue
This commit is contained in:
1 parent
b497b8635b
commit
eb70c7e196
2 files changed
+18
-7
No files matched your search
@@ -470,6 +470,10 @@ public final class EntityBeanIntercept implements Serializable {
|
|||||||
* Return the original value that was changed via an update.
|
* Return the original value that was changed via an update.
|
||||||
*/
|
*/
|
||||||
public Object getOrigValue(int propertyIndex) {
|
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) {
|
if (origValues == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -718,11 +722,6 @@ public final class EntityBeanIntercept implements Serializable {
|
|||||||
String propName = (prefix == null ? getProperty(i) : prefix + getProperty(i));
|
String propName = (prefix == null ? getProperty(i) : prefix + getProperty(i));
|
||||||
Object newVal = owner._ebean_getField(i);
|
Object newVal = owner._ebean_getField(i);
|
||||||
Object oldVal = getOrigValue(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)) {
|
if (notEqual(oldVal, newVal)) {
|
||||||
dirtyValues.put(propName, new ValuePair(newVal, oldVal));
|
dirtyValues.put(propName, new ValuePair(newVal, oldVal));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
package io.ebean.bean;
|
package io.ebean.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to for mutable information in EntityBeanIntercept.
|
||||||
|
*/
|
||||||
public interface MutableHash {
|
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);
|
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) {
|
default boolean isEqualToObject(Object obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Creates a new instance from the internal json string. This is an optional method.
|
||||||
|
*/
|
||||||
default Object get() {
|
default Object get() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user