Class SDOEqualityHelper
- All Implemented Interfaces:
EqualityHelper
Purpose: A helper class for checking deep or shallow equality of DataObjects.
ChangeSummary is not in scope for equality checking.
- Since:
- Oracle TopLink 11.1.1.0.0
- See Also:
-
Field Summary
Fields inherited from interface commonj.sdo.helper.EqualityHelper
INSTANCE -
Constructor Summary
ConstructorsConstructorDescriptionINTERNAL: This default constructor must be used in conjunction with the setHelperContext() function.SDOEqualityHelper(HelperContext aContext) Constructor that takes in a HelperContext instance that contains this equalityHelper.
This is the recommended constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanequal(DataObject dataObject1, DataObject dataObject2) Two DataObjects are equal(Deep) if they are equalShallow, all their compared Properties are equal, and all reachable DataObjects in their graphs excluding containers are equal.booleanequalShallow(DataObject dataObject1, DataObject dataObject2) Two DataObjects are equalShallow if they have the sameTypeand all their compared Properties are equal.INTERNAL: Return the helperContext containing this equalityHelper.voidsetHelperContext(HelperContext helperContext) INTERNAL: Set the helperContext if this equalityHelper was created using the default constructor.
-
Constructor Details
-
SDOEqualityHelper
public SDOEqualityHelper()INTERNAL: This default constructor must be used in conjunction with the setHelperContext() function. The custom constructor that takes a HelperContext parameter is recommended over this default constructor. -
SDOEqualityHelper
Constructor that takes in a HelperContext instance that contains this equalityHelper.
This is the recommended constructor.- Parameters:
aContext-
-
-
Method Details
-
equalShallow
Two DataObjects are equalShallow if they have the same
Returns true the objects have the same Type and all values of all compared Properties are equal.Typeand all their compared Properties are equal. The set of Properties compared are theinstance propertieswhere property.getType().isDataType() is true and property.getType() is not ChangeSummaryType.
Two of these Property values are equal if they are both notset, or set to an equal value dataObject1.get(property).equals(dataObject2.get(property))
If the type is a sequenced type, the sequence entries must be the same. For each entry x in the sequence where the property is used in the comparison, dataObject1.getSequence().getValue(x).equals( dataObject2.getSequence().getValue(x)) and dataObject1.getSequence().getProperty(x) == dataObject2.getSequence().getProperty(x) must be true.- Specified by:
equalShallowin interfaceEqualityHelper- Parameters:
dataObject1- DataObject to be compareddataObject2- DataObject to be compared- Returns:
- true the objects have the same Type and all values of all compared Properties are equal.
-
equal
Two DataObjects are equal(Deep) if they are equalShallow, all their compared Properties are equal, and all reachable DataObjects in their graphs excluding containers are equal. The set of Properties compared are the
instance propertieswhere property.getType().isDataType() is false, and is not a container property, ie !property.getOpposite().isContainment()
Two of these Property values are equal if they are both notset, or all the DataObjects they refer to areequalin the context of dataObject1 and dataObject2.
Note that properties to a containing DataObject are not compared which means two DataObject trees can be equal even if their containers are not equal.
If the type is a sequenced type, the sequence entries must be the same. For each entry x in the sequence where the property is used in the comparison, equal(dataObject1.getSequence().getValue(x), dataObject2.getSequence().getValue(x)) and dataObject1.getSequence().getProperty(x) == dataObject2.getSequence().getProperty(x) must be true.A DataObject directly or indirectly referenced by dataObject1 or dataObject2 can only be equal to exactly one DataObject directly or indirectly referenced by dataObject1 or dataObject2, respectively. This ensures that dataObject1 and dataObject2 are equal if the graph formed by all their referenced DataObjects have the same shape.
Returns true if the trees of DataObjects are equal(Deep).- Specified by:
equalin interfaceEqualityHelper- Parameters:
dataObject1- DataObject to be compareddataObject2- DataObject to be compared- Returns:
- true if the trees of DataObjects are equal(Deep).
-
getHelperContext
INTERNAL: Return the helperContext containing this equalityHelper.- Returns:
-
setHelperContext
INTERNAL: Set the helperContext if this equalityHelper was created using the default constructor.- Parameters:
helperContext-
-