You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Niclas Hedhman <ni...@hedhman.org> on 2004/07/29 08:22:59 UTC

[Proposal] equals() and hashCode() impl in Parameters

Gang,

It has come to my attention that o.a.a.f.parameters.Parameters is lacking 
equals() and hashCode() semantics.

It seems it is not defined anywhere, but there is no reason why it shouldn't 
have the same semantics as HashMap.

I am proposing that the equals() and hashCode() are implemented, so that 
identical internal HashMaps and readonly attribute, produces an equality.


WDYAT??


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 29 July 2004 14:22, Niclas Hedhman wrote:
> It has come to my attention that o.a.a.f.parameters.Parameters is lacking
> equals() and hashCode() semantics.
>
> It seems it is not defined anywhere, but there is no reason why it
> shouldn't have the same semantics as HashMap.
>
> I am proposing that the equals() and hashCode() are implemented, so that
> identical internal HashMaps and readonly attribute, produces an equality.

Awaiting the debate, I have already committed the additions of equals(), 
hashCode() and toString() to the Parameters class, for review and allowing me 
to continue with 'Parameter Overloading' feature in Merlin.


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 29 July 2004 14:22, Niclas Hedhman wrote:

> I am proposing that the equals() and hashCode() are implemented, so that
> identical internal HashMaps and readonly attribute, produces an equality.

I have added a simple Testcase which fails after a 'deep-copy' of an empty 
Parameters instance.

Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Monday 02 August 2004 21:57, Leo Simons wrote:
> Niclas Hedhman wrote:
> > Can someone (like Sutic :o) ) shed some 'big spotlight' on what this is
> > all about ??
>
> just badly designed. I commented on this a few months back I think, but
> I guess I forgot to actually finish the changes. PeterR had some useful
> comments in the archives I think.

Not much actually. PeterR only mentioned he used it, but not much else.

Perhaps, should just deprecate the classes for now, and have them removed in 
AF5 or AF6?


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Leo Simons <ls...@jicarilla.org>.
Niclas Hedhman wrote:
> Can someone (like Sutic :o) ) shed some 'big spotlight' on what this is all 
> about ??

just badly designed. I commented on this a few months back I think, but 
I guess I forgot to actually finish the changes. PeterR had some useful 
comments in the archives I think.

- LSD


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Monday 02 August 2004 20:21, Niclas Hedhman wrote:

Perhaps I am completely misunderstanding what a ValuedEnum is all about...

The 'interesting' part of existing testcase is;

        public static final Color RED = new Color( "Red", 0 );
        public static final Color RED_NEGATIVE = new Color( "Red", -1 );

        assertTrue( Color.RED.equals( Color.RED_NEGATIVE ) );

Can someone (like Sutic :o) ) shed some 'big spotlight' on what this is all 
about ??


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Monday 02 August 2004 20:21, Niclas Hedhman wrote:

> contains a final public int hashCode()

Ooops, it was equals() that was final, not hashCode.
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Monday 02 August 2004 20:05, Leo Simons wrote:

> all value objects in framework should have equals() and hashCode(), some
> have and should have toString(); and they should be serializable :-D

Ok, slowly digging through them all :o)

./api/src/java/org/apache/avalon/framework/Enum.java

contains a final public int hashCode()

and 
./api/src/java/org/apache/avalon/framework/ValuedEnum.java
extends Enum

And then it is possible to have two Enums considered equal() from name alone.

Both are abstract classes, so it is expected that something extends these, and 
inherit the same problem.


CTR; I am removing the "final", and adding hashCode() and equals() to 
ValuedEnum.


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [Proposal] equals() and hashCode() impl in Parameters

Posted by Leo Simons <ls...@jicarilla.org>.
Niclas Hedhman wrote:
> It has come to my attention that o.a.a.f.parameters.Parameters is lacking 
> equals() and hashCode() semantics.
> 
> It seems it is not defined anywhere, but there is no reason why it shouldn't 
> have the same semantics as HashMap.
> 
> I am proposing that the equals() and hashCode() are implemented, so that 
> identical internal HashMaps and readonly attribute, produces an equality.
> 
> WDYAT??

all value objects in framework should have equals() and hashCode(), some 
have and should have toString(); and they should be serializable :-D

- LSD


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org