equals

Determines whether two objects (a left-hand-side object and a right-hand-side object) are equal.

Number values are converted to CER's own numerical format (backed by java.math.BigDecimal) before comparison; differences in leading or trailing zeros are ignored.

null values are compared safely; if both left hand side and right hand side are null, then the equals expression returns true; if only one of the left hand side and right hand side values are null, then the equals expression returns false.

<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_equals"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">
  <Class name="EqualsExampleRuleClass">

    <!-- TRUE -->
    <Attribute name="identicalStrings">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <equals>
          <String value="A String"/>
          <String value="A String"/>
        </equals>
      </derivation>
    </Attribute>

    <!-- FALSE -->
    <Attribute name="differentStrings">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <equals>
          <String value="A String"/>
          <String value="A different String"/>
        </equals>
      </derivation>
    </Attribute>

    <!-- TRUE -->
    <Attribute name="identicalNumbers">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <equals>
          <!-- These numbers are the same,
            disregarding trivial
            differences in leading/trailing
            zeroes -->
          <Number value="123"/>
          <Number value="000123.000"/>
        </equals>
      </derivation>
    </Attribute>

    <!-- FALSE -->
    <Attribute name="differentTypes">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <equals>
          <!-- These objects are of
            different types, so are
            not equal even if they
            "look" the same.-->
          <String value="123"/>
          <Number value="123"/>
        </equals>
      </derivation>
    </Attribute>

    <!-- FALSE -->
    <Attribute name="oneNull">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <equals>
          <null/>
          <Number value="456"/>
        </equals>
      </derivation>
    </Attribute>

    <!-- TRUE -->
    <Attribute name="twoNulls">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <equals>
          <null/>
          <null/>
        </equals>
      </derivation>
    </Attribute>

  </Class>

</RuleSet>