Generated Equals in Webservice Stub

All created stub web services from our backend have an equivalent method similar to this:

private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
    if (!(obj instanceof PropertyData)) return false;
    PropertyData other = (PropertyData) obj;
    if (obj == null) return false;
    if (this == obj) return true;
    if (__equalsCalc != null) {
        return (__equalsCalc == obj);
    }
    __equalsCalc = obj;
    boolean _equals;
    _equals = true && 
        ((this.key==null && other.getKey()==null) || 
         (this.key!=null &&
          this.key.equals(other.getKey()))) &&
        ((this.value==null && other.getValue()==null) || 
         (this.value!=null &&
          this.value.equals(other.getValue())));
    __equalsCalc = null;
    return _equals;
}

Can someone please explain the trick to me __equalsCalc? I just do not understand. It is not used anywhere else in the class. The way I see it is not entirely accurate when calculating "equality." However, declared equal synchronized. Therefore, at any time there can be only one thread. I don’t see why if (__equalsCalc != null)it should always be true.

Please show me my stupid misunderstanding; -)

EDIT: I am new to the project, and so my answer may be wrong. But if I track it correctly, the method is generated using the -wsdl2java axis

+5
2

, - - , , .

, , , .

? ? , ?

EDIT: , , WSDL2Java, () :

    // The __equalsCalc field and synchronized method are necessary
    // in case the object has direct or indirect references to itself.

:

    // Have we been here before ? return true if yes otherwise false
    pw.println("        if (__equalsCalc != null) {");
    pw.println("            return (__equalsCalc == obj);");
    pw.println("        }");

, , , , , .

+6

__equalsCal Equals. , , ,

EDIT: , ,

__equalsCalc = null;

, , , .

-1

All Articles