[YANGTOOLS-37] Implement correct equals for array fields Created: 04/Oct/13  Updated: 10/Apr/22  Resolved: 10/Oct/13

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Dana Kutenicsova Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


External issue ID: 103
Priority: Normal

 Description   

Having a field, that is an array in a generated DTO. Equals method looks like this:
...
else if(!_value.equals(other._value)) {
return false;
}
...

That will always return false even if both objects are equal. Replace equals with:

...
else if (!Arrays.equals(this._value, other._value)) {
return false;
}



 Comments   
Comment by Dana Kutenicsova [ 04/Oct/13 ]

The same goes for hashcode:

Use: result = prime * result + Arrays.hashCode(this._value);

Comment by Martin Vitez [ 10/Oct/13 ]

Fixed in binding-generator version 0.6.0-SNAPSHOT.

https://git.opendaylight.org/gerrit/#/c/1796/

Generated at Wed Feb 07 20:52:05 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.