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 74209

Summary: "generate" features
Product: editor Reporter: wqtnetbeans <wqtnetbeans>
Component: Completion & TemplatesAssignee: Dusan Balek <dbalek>
Status: RESOLVED DUPLICATE    
Severity: blocker CC: hmichel, msauer
Priority: P3    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description wqtnetbeans 2006-03-30 17:30:12 UTC
It'd be nice to have one-key-stroke code generations on an existing class

1. constructor
2. getter/setter 
3. equals() and hashCode()
4. toString()
5. JUnit test
6. over ride method...
7. delegate method...

Those are from IntelliJ, which I think is very neat. Among them, 2, 5, and 6 are
already available in NB; but it'd nice to have them under one "generate..." menu
or something like that.

Below is a sample from IntelliJ. Note that only user input is the two String
feilds; the rest are generated by the IDE.

public class MyClass {
   String f1;
   String f2;

   public boolean equals(Object o) {
       if (this == o) return true;
       if (o == null || getClass() != o.getClass()) return false;

       final MyClass myClass = (MyClass) o;

       if (f1 != null ? !f1.equals(myClass.f1) : myClass.f1 != null)
return false;
       if (f2 != null ? !f2.equals(myClass.f2) : myClass.f2 != null)
return false;

       return true;
   }

   public int hashCode() {
       int result;
       result = (f1 != null ? f1.hashCode() : 0);
       result = 29 * result + (f2 != null ? f2.hashCode() : 0);
       return result;
   }


   public String toString() {
       return "MyClass{" +
               "f1='" + f1 + '\'' +
               ", f2='" + f2 + '\'' +
               '}';
   }
}

There is list discussion at
http://www.netbeans.org/servlets/ReadMsg?list=nbusers&msgNo=67017

Thanks,
Qingtian
Comment 1 Max Sauer 2006-06-06 10:15:59 UTC
1. This is possible from inside explorer
2. This is possible through refactoring
3.,4.,6. -- try 'override methods, Ctrl+I'
5. Ctrl-Shift-U
6. What do you mean by "delegate method"? Like charAt etc. for a String?

As for the Generate menu, we will discuss this.

Thanks, 
Comment 2 wqtnetbeans 2006-09-29 17:14:33 UTC

*** This issue has been marked as a duplicate of 85814 ***