|
|
| Added: |
> > |
How about a slight tweak to toString(), to add a super.toString()
call if the super class isn't Object?
e.g. return "[Wrapper: " + super.toString() ...
-- GwynEvans - 09 Sep 2002
|
|
|
| Changed: |
< < |
CanonicizerDoclet - version 0.3
| > > |
CanonicizerDoclet - version 0.3b - (28 Jun 2002)
|
| Changed: |
< < |
-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet03.jar
| > > |
-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet03b.jar
|
| Added: |
> > |
|
| Changed: |
< < |
%META:FILEATTACHMENT{name="canonicizerDoclet03.jar" attr="" comment="doclet jar v0.3" date="1024432139" path="C:\canonicizerDoclet03.jar" size="14709" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet03.zip" attr="" comment="project source v0.3" date="1024432362" path="C:\canonicizerDoclet03.zip" size="153266" user="AlainRavet" version="1.1"}%
| > > |
%META:FILEATTACHMENT{name="canonicizerDoclet03.jar" attr="h" comment="doclet jar v0.3" date="1024432139" path="C:\canonicizerDoclet03.jar" size="14709" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet03.zip" attr="h" comment="project source v0.3" date="1024432362" path="C:\canonicizerDoclet03.zip" size="153266" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet03b.jar" attr="" comment="doclet jar v0.3b" date="1025279244" path="C:\dev\Tool\idea629\lib\canonicizerDoclet03b.jar" size="21619" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet3b.zip" attr="" comment="project source v0.3b" date="1025279355" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet3b.zip" size="242146" user="AlainRavet" version="1.1"}% |
|
|
| Changed: |
< < |
CanonicizerDoclet - version 0.2
| > > |
CanonicizerDoclet - version 0.3
|
| Changed: |
< < |
result = 37 * result + oneString.hashCode() ;
| > > |
result = 37 * result + hashCodeOrZeroIfNull(oneString) ;
|
| Changed: |
< < |
-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet.jar
| > > |
-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet03.jar
|
| Added: |
> > |
- v 0.3
- added : null handling in hashCode()
- test code refactored
|
| Changed: |
< < |
- add a GUI to select/exclude members. (v 0.3)
- make into a plugin (v0.4 : will require JDK 1.4)
- improve handling of null values for objects, and strings.
| > > |
- add a GUI to select/exclude members. (v 0.4)
- make into a plugin (v0.5 : will require JDK 1.4)
|
| Changed: |
< < |
I could easily change it the same way I added null handling in equals()
(replacing this.equals(o) by areEqualsOrBothNull(this,o))
But I'm not convinced it's going in the right direction; I tend to prefer letting NPE go the surface.
I almost regret the equals improvment.<grin>
I'm open to suggestions.
| > > |
done
|
| Deleted: |
< < |
|
| Changed: |
< < |
%META:FILEATTACHMENT{name="canonicizerDoclet02.jar" attr="" comment="doclet jar v0.2" date="1023483643" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.jar" size="14738" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet02.zip" attr="" comment="project source v0.2" date="1023484036" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.zip" size="152650" user="AlainRavet" version="1.1"}%
| > > |
%META:FILEATTACHMENT{name="canonicizerDoclet02.jar" attr="h" comment="doclet jar v0.2" date="1023483643" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.jar" size="14738" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet02.zip" attr="h" comment="project source v0.2" date="1023484036" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.zip" size="152650" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet03.jar" attr="" comment="doclet jar v0.3" date="1024432139" path="C:\canonicizerDoclet03.jar" size="14709" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet03.zip" attr="" comment="project source v0.3" date="1024432362" path="C:\canonicizerDoclet03.zip" size="153266" user="AlainRavet" version="1.1"}% |
|
|
| Changed: |
< < |
&& areEqualsOrBothNull (obj.oneString, this.oneString) ;
| > > |
&& areEqualsOrBothNull (obj.oneString, this.oneString) ;
|
| Changed: |
< < |
result = 37 * result + oneString.hashCode() ;
| > > |
result = 37 * result + oneString.hashCode() ;
|
| Changed: |
< < |
- improve handling of null values for objects, and strings. (added in v 0.2)
| > > |
- add a GUI to select/exclude members. (v 0.3)
- make into a plugin (v0.4 : will require JDK 1.4)
- improve handling of null values for objects, and strings.
|
| Deleted: |
< < |
|
| Added: |
> > |
I could easily change it the same way I added null handling in equals()
(replacing this.equals(o) by areEqualsOrBothNull(this,o))
But I'm not convinced it's going in the right direction; I tend to prefer letting NPE go the surface.
I almost regret the equals improvment.<grin>
I'm open to suggestions.
-- AlainRavet - 18 Jun 2002
|
|
|
| Changed: |
< < |
This rules! Thanks Alain!
| > > |
Null handling for hashCode would be nice.
|
| Changed: |
< < |
-- GlenStampoultzis - 04 Jun 2002
| > > |
-- GlenStampoultzis - 18 Jun 2002 |
|
|
| Changed: |
< < |
This rules! Thanks Alain! Aside from not handling nulls (added in v 0.2) it works rather nicely.
| > > |
This rules! Thanks Alain! |
|
|
| Changed: |
< < |
CanonicizerDoclet - version 0.1
| > > |
CanonicizerDoclet - version 0.2
|
| Changed: |
< < |
| > > |
|
| Changed: |
< < |
&& obj.oneString .equals( this.oneString )
;
| > > |
&& areEqualsOrBothNull (obj.oneString, this.oneString) ;
|
| Changed: |
< < |
| > > |
..
..
|
| Changed: |
< < |
| > > |
|
| Added: |
> > |
- v 0.2
- added : null handling in equals()
- v 0.1
|
| Changed: |
< < |
- improve handling of null values for objects, and strings.
| > > |
- improve handling of null values for objects, and strings. (added in v 0.2)
|
| Changed: |
< < |
This rules! Thanks Alain! Aside from not handling nulls it works rather nicely.
| > > |
This rules! Thanks Alain! Aside from not handling nulls (added in v 0.2) it works rather nicely.
|
| Changed: |
< < |
%META:FILEATTACHMENT{name="canonicizerDoclet.jar" attr="" comment="doclet jar v0.1" date="1023138160" path="C:\canonicizerDoclet.jar" size="13518" user="AlainRavet" version="1.1"}%
| > > |
%META:FILEATTACHMENT{name="canonicizerDoclet.jar" attr="h" comment="doclet jar v0.1" date="1023138160" path="C:\canonicizerDoclet.jar" size="13518" user="AlainRavet" version="1.1"}%
|
| Changed: |
< < |
%META:FILEATTACHMENT{name="canonicizerDoclet.zip" attr="" comment="project source v0.1 " date="1023138490" path="C:\canonicizerDoclet.zip" size="37591" user="AlainRavet" version="1.1"}%
| > > |
%META:FILEATTACHMENT{name="canonicizerDoclet.zip" attr="h" comment="project source v0.2" date="1023138490" path="C:\canonicizerDoclet.zip" size="37591" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet02.jar" attr="" comment="doclet jar v0.2" date="1023483643" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.jar" size="14738" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet02.zip" attr="" comment="project source v0.2" date="1023484036" path="C:\Documents and Settings\aravet\Desktop\canonicizerDoclet02.zip" size="152650" user="AlainRavet" version="1.1"}% |
|
|
| Added: |
> > |
Why only private members? Just because an instance variable is non-private doesn't mean it's not part of the definition of the object. And just because Java purists don't like non-private instance variables doesn't mean they don't serve a purpose. (I, for one, see little reason for getters and setters in classes whose only use is within the scope of a single project or even a single multi-project codebase - you can just use "Encapsulate field(s)" later if you find you need to change the way a "property" is stored.)
Also, a suggestion: have some kind of extra Javadoc tag for telling this thing to ignore a variable when making up its methods.
-- WalterMundt - 04 Jun 2002 |
|
|
| Changed: |
< < |
- hashCode() implements Joshua Bloch's 'Effective Java' recipe.
| > > |
|
|
|
| Added: |
> > |
This rules! Thanks Alain! Aside from not handling nulls it works rather nicely.
-- GlenStampoultzis - 04 Jun 2002 |
|
|
| Added: |
> > |
%META:TOPICINFO{author="AlainRavet" date="1023138780" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="AlainRavet"}%
CanonicizerDoclet - version 0.1
(please send comments and bug reports to alain_ravet@yahooNOSPAM321.com)
You can add your comments and suggestions here.
For a given class, this doclet generates :
- toString()
- hashCode()
- equals ()
based on the class private non static members.
The generated code for those 3 methods is sent to the console, and copied into the clipboard.
Notes :
- hashCode() implements Joshua Bloch's 'Effective Java' recipe.
- toString() format : "[ClassName: valueField1, valueField2, ..]"
- ex: "[Name: John, Smith]"
- arrays are not handled, just signaled (code can't compile).
- If there is no array member in the class, the skeleton should be functional, and can be used as-is.
More :
- open the class in the editor
- call the doclet external tool
- the generated code is in the clipboard, and
the generated code is displayed in the console.
Class to "canonicize" :
public class SampleClass
{
private byte aByte ;
private String oneString ;
}
Generated code :
public boolean equals (Object o)
{
if (this == o) return true ;
if (! (o instanceof SampleClass )) return false ;
final SampleClass obj = (SampleClass) o;
return
obj.aByte == aByte
&& obj.oneString .equals( this.oneString )
;
}
public String toString ()
{
return "[SampleClass: "
+ aByte
+ "," + oneString
+ "]" ;
}
public int hashCode ()
{
int result = 17;
result = 37 * result + (int)aByte ;
result = 37 * result + oneString.hashCode() ;
return result ;
}
}
- create a new external tool
- edit the new tool :
Edit Tool :
------------------------------------------------------------------------------------
Name : Canonicizer doclet
Open Console : checked
Program : $JDKPath$\bin\javadoc.exe
Parameters : -private
-doclet com.intellij.contrib.canonicizer.Canonicizer
-docletpath C:\dev\Tool\idea628\lib\canonicizerDoclet.jar
$FilePath$
Working directory : $JDKPath$\bin
------------------------------------------------------------------------------------
- improve handling of null values for objects, and strings.
- add handling for arrays members
- generates the corresponding tester class.
%META:FILEATTACHMENT{name="canonicizerDoclet.jar" attr="" comment="doclet jar v0.1" date="1023138160" path="C:\canonicizerDoclet.jar" size="13518" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet.dir" attr="h" comment="project source v0.1" date="1023138214" path="C:\canonicizerDoclet.dir" size="37591" user="AlainRavet" version="1.1"}%
%META:FILEATTACHMENT{name="canonicizerDoclet.zip" attr="" comment="project source v0.1 " date="1023138490" path="C:\canonicizerDoclet.zip" size="37591" user="AlainRavet" version="1.1"}% |
View
| Diffs | r1.13 | > | r1.12 | > | r1.11
| More
|
|