PL-8152 Compare property values considering reference equality for Instance subclasses instead of usual equals

This commit is contained in:
Yuriy Artamonov 2017-01-18 14:41:05 +04:00
parent 768e11e003
commit 2a9589e3e6
3 changed files with 6 additions and 7 deletions

View File

@ -120,14 +120,13 @@ public abstract class AbstractInstance implements Instance {
/**
* Set value to property in instance
*
* @deprecated For internal use only. Parameter checkEquals now does not affect logic. Use {@link #setValue(String, Object)}
* For internal use only. Use {@link #setValue(String, Object)}
*
* @param name property name
* @param value value
* @param checkEquals check equals for previous and new value.
* If flag is true and objects equals, then setter will not be invoked
*/
@Deprecated
public void setValue(String name, Object value, boolean checkEquals) {
Object oldValue = getValue(name);
if ((!checkEquals) || (!InstanceUtils.propertyValueEquals(oldValue, value))) {

View File

@ -19,13 +19,13 @@ package com.haulmont.cuba.core.entity;
import com.haulmont.chile.core.annotations.MetaProperty;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.impl.AbstractInstance;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.core.entity.annotation.SystemLevel;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.Metadata;
import com.haulmont.cuba.core.global.UuidProvider;
import com.haulmont.cuba.core.sys.CubaEnhanced;
import com.haulmont.cuba.core.sys.CubaEnhancingDisabled;
import org.apache.commons.lang.ObjectUtils;
import java.util.UUID;
@ -78,7 +78,7 @@ public abstract class AbstractNotPersistentEntity
@Override
public void setValue(String property, Object obj, boolean checkEquals) {
Object oldValue = getValue(property);
if ((!checkEquals) || (!ObjectUtils.equals(oldValue, obj))) {
if ((!checkEquals) || (!InstanceUtils.propertyValueEquals(oldValue, obj))) {
getMethodsCache().invokeSetter(this, property, obj);
if (!(this instanceof CubaEnhanced)) {
propertyChanged(property, oldValue, obj);

View File

@ -19,10 +19,10 @@ package com.haulmont.cuba.core.entity;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.impl.AbstractInstance;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.core.entity.annotation.SystemLevel;
import com.haulmont.cuba.core.global.UuidProvider;
import com.haulmont.cuba.core.sys.CubaEnhancingDisabled;
import org.apache.commons.lang.ObjectUtils;
import java.util.LinkedHashMap;
import java.util.Map;
@ -98,7 +98,7 @@ public class KeyValueEntity
@Override
public void setValue(String name, Object value, boolean checkEquals) {
Object oldValue = getValue(name);
if ((!checkEquals) || (!ObjectUtils.equals(oldValue, value))) {
if ((!checkEquals) || (!InstanceUtils.propertyValueEquals(oldValue, value))) {
properties.put(name, value);
propertyChanged(name, oldValue, value);
}
@ -150,4 +150,4 @@ public class KeyValueEntity
id = "?(" + uuid + ")";
return "sys$KeyValueEntity-" + id;
}
}
}