Bug 302714 - generate java.lang.Comparable.compareTo() method
Summary: generate java.lang.Comparable.compareTo() method
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-12 09:07 EST by Nikolay Metchev CLA
Modified: 2010-02-12 09:26 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Metchev CLA 2010-02-12 09:07:30 EST
Build Identifier: I20100129-1300

This will be very similar to the generate equals() and hashcode() functionality that is already available in eclipse. If you have a class that implements Comparable and want Eclipse to implement the compareTo for you. I expect it will prompt you which fields to use (just like equals and hashcode). It should of course complain if you choose fields that aren't primitive and don't implement Comparable. 

Reproducible: Always
Comment 1 Nikolay Metchev CLA 2010-02-12 09:10:07 EST
Also I realize that apache commons has a CompareToBuilder and a plugin to go with it (http://commonclipse.sourceforge.net/index.html), however the code that apache commons uses is not as efficient as a template version will be. Object creation in the compareTo() method can cause quite severe performance problems in certain circumstances.