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 163561 - options to equals-hashcode generator
Summary: options to equals-hashcode generator
Status: RESOLVED DUPLICATE of bug 156994
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-24 10:31 UTC by aekold
Modified: 2013-08-10 13:20 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 aekold 2009-04-24 10:31:21 UTC
Have suggestions to improve equals code:
1. add block to the start of method:
        if (this == obj) {
            return true;
        }
2. add checkbox to allow check by instance but not class:
        if (!(obj instanceof <currenttype>)) {
            return false;
        }
this option will be useful for some JPA implementations whos getClass is not the same as current.
Comment 1 aekold 2009-04-24 10:34:24 UTC
Here is some code from my EqualsHashCodeGenerator.java:
        // if (obj == this) return true;
        statements.add(make.If(make.Binary(Tree.Kind.EQUAL_TO, make.Identifier("this"), make.Identifier("obj")), 
make.Return(make.Identifier("true")), null));


        //if (!(obj instanceof <this type>)) return false;
        statements.add(make.If(make.Unary(Tree.Kind.LOGICAL_COMPLEMENT, 
make.Parenthesized(make.InstanceOf(make.Identifier("obj"), make.Type(type)))), make.Return(make.Identifier("false")), 
null));
Comment 2 markiewb 2013-08-10 13:20:55 UTC

*** This bug has been marked as a duplicate of bug 156994 ***