# Code 1  in generated java classes

**URL:** <https://techcommunity.softwareag.com/t/code-1-in-generated-java-classes/57897>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Adabas-Add-on-Products, Other-Adabas-add-on-products, Adabas-SOA-Gateway\
**Created:** [March 6, 2006, 7:42pm UTC](https://techcommunity.softwareag.com/t/code-1-in-generated-java-classes/57897 "2006-03-06T19:42:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [March 6, 2006, 7:42pm UTC](https://techcommunity.softwareag.com/t/code-1-in-generated-java-classes/57897/1 "2006-03-06T19:42:03Z")

</div>

Hi all.

is there anyone who can tell me 1. what the following code is good for and 2. give me some hints about what the code is actually does [small java course]. I found this code snippet in some other java programs.

```auto
private java.lang.Object __equalsCalc = null;
    public synchronized boolean equals(java.lang.Object obj) {
        if (!(obj instanceof AdabasEmployeesTypeIncome)) return false;
        AdabasEmployeesTypeIncome other = (AdabasEmployeesTypeIncome) obj;
        if (obj == null) return false;
        if (this == obj) return true;
        if (__equalsCalc != null) {
            return (__equalsCalc == obj);
        }
        __equalsCalc = obj;
        boolean _equals;
        _equals = true && 
            ((this.currencyCode==null && other.getCurrencyCode()==null) || 
             (this.currencyCode!=null &&
              this.currencyCode.equals(other.getCurrencyCode()))) &&
            ((this.annualSalary==null && other.getAnnualSalary()==null) || 
             (this.annualSalary!=null &&
              java.util.Arrays.equals(this.annualSalary, other.getAnnualSalary()))) &&
            ((this.annualBonus==null && other.getAnnualBonus()==null) || 
             (this.annualBonus!=null &&
              java.util.Arrays.equals(this.annualBonus, other.getAnnualBonus())));
        __equalsCalc = null;
        return _equals;
    }
```

Best Regards

Dago

---

<div class="post-metadata">

**Author:** ![Bill\_Leeney](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@Bill\_Leeney](https://techcommunity.softwareag.com/u/Bill_Leeney)\
**Post date:** [March 7, 2006, 3:44pm UTC](https://techcommunity.softwareag.com/t/code-1-in-generated-java-classes/57897/2 "2006-03-07T15:44:14Z")

</div>

Hi,  
I would expect to find this code in the definition of class AdabasEmployeesTypeIncome, where it overrides the “.equals()” comparison method. You can use this method in a statement like

```auto

AdabasEmployeesTypeIncome myIncome = someIncome;
if (myIncome.equals(someOtherIncome)) { do something };
```

Basically it locks the object being compared (synchronized), then tests the parameter object (which can be any type of Object) to make sure it is actually of type “AdabasEmployeesTypeIncome” (two objects can’t be equal if they are of different type). If not, the method returns false. If the parameter type is correct, the code casts the parameter object into its correct type to get access to the properties it needs to compare. If the object being compared is null, the result is false. If both objects have the same “handle” (==) they must be the same object, therefore return true. The code then returns true if all the individual properties of both objects are the same, or null. Otherwise it returns false. You get the idea.

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [March 7, 2006, 4:42pm UTC](https://techcommunity.softwareag.com/t/code-1-in-generated-java-classes/57897/3 "2006-03-07T16:42:10Z")

</div>

Thank’s a lot for your reply.  
Yes , the last part of your reply gives me the idea whay and what happens.

Best regards  
Dago

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:38pm UTC](https://techcommunity.softwareag.com/t/code-1-in-generated-java-classes/57897/4 "2021-04-02T14:38:55Z")

</div>


