This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 233397 - Insert Code/hashCode, equals, toString: offer an alternative Implementation
Summary: Insert Code/hashCode, equals, toString: offer an alternative Implementation
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-25 09:56 UTC by tomzi
Modified: 2013-08-16 12:25 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomzi 2013-07-25 09:56:24 UTC
Let me choose to use apache.commons HashcodeBuiler/EqualsBuilder/ToStringBuilder

Which in our project we should only use these ways to implement hashCode....

Product Version = NetBeans IDE 7.3 (Build 201302132200)
Operating System = Linux version 3.8.0-26-generic running on amd64
Java; VM; Vendor = 1.7.0_25
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Comment 1 tomzi 2013-08-12 08:21:57 UTC
I think that wouldn't be 'too' complecated to do and it would improve code readability and shortness code, to have 

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MobileProductDetails other = (MobileProductDetails) obj;
        return new EqualsBuilder().
            append(this.getMsisdn(), other.getMsisdn()).
            append(this.getImsi(), other.getImsi()).isEquals();
    }

instead of 

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MobileProductDetails other = (MobileProductDetails) obj;
        if (!Objects.equals(this.msisdn, other.msisdn)) {
            return false;
        }
        if (!Objects.equals(this.imsi, other.imsi)) {
            return false;
        }
        return true;
    }

Especially if the rest of the code in the modules only uses EqualsBuilder... which NB does not suppert yet :)