equals()

Compare this business object's attribute values with those in the input business object, including child business objects.

Syntax

-boolean equals(Object inputBusObj)

Parameters

inputBusObj
A business object to compare with this business object.

Return values

Returns true if the values of all attributes are the same; otherwise, returns false.

Exceptions

CollaborationException--The equals() method can set the following exception type for this exception:

Notes

This method compares this business object's attribute values with those in the input business object. If the business objects are hierarchical, the comparison includes all attributes in the child business objects.

  1. Passing in the business object as an Object ensures that this equals() method overrides the Object.equals() method.
  2. In the comparison, a null value in the source object is considered equivalent to any value to which it is compared and results in a return of true. The results from this method may not be symmetrical based on the order of comparison. A comparison of A.equals(B) may not be the same as B.equals(A). The second example shows the results of various comparisons of the same objects.
  3. The order of the children does effect the results of this method. If everything else matches, a mismatch in the order will return a false value.
  4. The verb has no effect on the outcome of the comparison.

See also

equalKeys(), equalsShallow()

Examples

The following example compares all attributes of order2 to all attributes of order1 and assigns the result of the comparison to the variable areEqual. The comparison includes the attributes of child business objects, if any.

boolean areEqual = order1.equals(order2);

The next example compares triggeringBusObj to sourceBusObj and shows how the order of the comparison affects the results.

logInfo("***Comparing triggering BO to empty Source BO");
if (triggeringBusObj.equals(SourceBusObj)) {
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - TRUE");
} else
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - FALSE");
if (SourceBusObj.equals(triggeringBusObj)) {
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - TRUE");
} else
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - FALSE");
 
logInfo("*** Copying Source BO verb from triggering BO");
SourceBusObj.copy(triggeringBusObj);
if (triggeringBusObj.equals(SourceBusObj)) {
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - TRUE");
} else
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - FALSE");
if (SourceBusObj.equals(triggeringBusObj)) {
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - TRUE");
} else
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - FALSE");
 
logInfo("*** Setting Source BO verb to Update");
SourceBusObj.setVerb("Update");
if (triggeringBusObj.equals(SourceBusObj)) {
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - TRUE");
} else
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - FALSE");
if (SourceBusObj.equals(triggeringBusObj)) {
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - TRUE");
} else
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - FALSE");
 
logInfo("*** Swapping order of Source BO children");
BusObjArray TempArray = SourceBusObj.getBusObjArray("Attr3");
TempArray.swap(0,1);
if (triggeringBusObj.equals(SourceBusObj)) {
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - TRUE");
} else
  logInfo("**** triggeringBusObj.equals(SourceBusObj) - FALSE");
if (SourceBusObj.equals(triggeringBusObj)) {
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - TRUE");
} else
  logInfo("**** SourceBusObj.equals(triggeringBusObj) - FALSE");

The previous code gives the following results:

[Mesg: Info ***Comparing triggering BO to empty Source BO]
[Mesg: Info **** triggeringBusObj.equals(SourceBusObj) - FALSE]
[Mesg: Info **** SourceBusObj.equals(triggeringBusObj) - TRUE]
[Mesg: Info *** Copying Source BO from triggering BO]
[Mesg: Info **** triggeringBusObj.equals(SourceBusObj) - TRUE]
[Mesg: Info **** SourceBusObj.equals(triggeringBusObj) - TRUE]
[Mesg: Info *** Setting Source BO verb to Update]
[Mesg: Info **** triggeringBusObj.equals(SourceBusObj) - TRUE]
[Mesg: Info **** SourceBusObj.equals(triggeringBusObj) - TRUE]
[Mesg: Info *** Swapping order of Source BO children]
[Mesg: Info **** triggeringBusObj.equals(SourceBusObj) - FALSE]
[Mesg: Info **** SourceBusObj.equals(triggeringBusObj) - FALSE]

Copyright IBM Corp. 1997, 2004