avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: Why Version.equals( final Version other )?
Date Fri, 14 Sep 2001 13:24:36 GMT


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" <paulo.gaspar@krankikom.de>
> To: "Avalon Development" <avalon-dev@jakarta.apache.org>
> 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:donaldp@apache.org]
> > > 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: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message