Eung-ju Park a �crit :
> 
> Hmm...
> No problem with common usages.
> But may cause problem with collections.

...and all code that uses the "equals(Object)" method. "equals(Object)"
and "equals(Version)" have different signatures and are therefore
different methods.

This means for example it isn't possible to use Version objects as keys
of a HashMap and retrieve the values with new Version objects describing
the same version :
   map.put(new Version(1,0,0), "Description of version 1.0.0");
   map.get(new Version(1,0,0)) --> null !

Is is the intended contract for Version ?

> 
> ----- Original Message -----
> From: "Paulo Gaspar" <[EMAIL PROTECTED]>
> To: "Avalon Development" <[EMAIL PROTECTED]>
> Sent: Friday, September 14, 2001 10:13 PM
> Subject: RE: Why Version.equals( final Version other )?
> 
> > > Well I like the type safety, however you could also easily implement
> >
> > But Peter, since any class inherits a method
> >   boolean equals(Object obj)
> >
> > from Object, you still have no type safe equals() method just by
> > implementing
> >   boolean equals( final Version other )
> >
> > since any call with a non Version compatible argument can be handled
> > by the Object.equals() implementation.
> >
> >
> > Unless you use a different method name, what is the advantage of this
> > type-safe version?
> > Am I missing something?
> >
> >
> > Have fun,
> > Paulo Gaspar
> >
> > > -----Original Message-----
> > > From: Peter Donald [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, September 13, 2001 3:17 PM
> > > To: Avalon Development
> > > Subject: Re: Why Version.equals( final Version other )?
> > >
> > >
> > > On Thu, 13 Sep 2001 23:15, Eung-ju Park wrote:
> > > > Why use "boolean equals( final Version other )"
> > > > instead of "boolean equals( final Object other )"?
> > >
> > > Well I like the type safety, however you could also easily implement
> > >
> > > public boolean equals( final Object other )
> > > {
> > >   if( other instanceof Version ) return equals( (Version)other );
> > >   else return false;
> > > }
> > >
> > > --
> > > Cheers,
> > >
> > > Pete
> > >
> > > "abandon all hope , ye who enter here" - dante, inferno
> > >

-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to