Re: hashCode question (was Re: Silly Java question)

2005-12-27 Thread Michael Barker
The guidelines I've seen say that if two items are equal, then their hashcodes should match. If they are unequal, their hashcodes should not match. I have implemented the equals function like so: public boolean equals(Object that) { if (that == this) return true; if

Re: Silly Java question

2005-12-27 Thread Roman Kennke
Hi Jeff, I'm just beating on the KerberosPrincipal class, and am trying to deal the comments given by people. The problem I'm having is that I have a name string and a type int. This is the comment at the top of my equals function: * From Section 7.2 of rfc1510: When comparing

Re: hashCode question (was Re: Silly Java question)

2005-12-27 Thread Per Bothner
Michael Barker wrote: Given that the toString() must be the same in order to be equal Huh? I don't believe there is any such requirement. One would normally expect toString to match for equal objects, but it is not required. Atter all, the default toString will not satisfy this requirement

Re: hashCode question (was Re: Silly Java question)

2005-12-27 Thread Michael Barker
On Tue, 2005-12-27 at 10:26 -0800, Per Bothner wrote: Michael Barker wrote: Given that the toString() must be the same in order to be equal Huh? I don't believe there is any such requirement. One would normally expect toString to match for equal objects, but it is not required. Atter

Re: hashCode question (was Re: Silly Java question)

2005-12-27 Thread Per Bothner
Michael Barker wrote: From the equals() code, its applicable in this case: // The toString output must match. if (! toString().equals(((KerberosPrincipal)that).toString())) return false; In your message you did phrase things in terms of general contracts. More to the point:

Re: hashCode question (was Re: Silly Java question)

2005-12-27 Thread Michael Barker
On Tue, 2005-12-27 at 11:14 -0800, Per Bothner wrote: Michael Barker wrote: From the equals() code, its applicable in this case: // The toString output must match. if (! toString().equals(((KerberosPrincipal)that).toString())) return false; In your message you did

hashCode question (was Re: Silly Java question)

2005-12-26 Thread Jeff Bailey
Le lundi 26 décembre 2005 à 09:50 -0500, Brian Jones a écrit : * From Section 7.2 of rfc1510: When comparing names, a name of type * UNKNOWN will match principals authenticated with names of any type. * A principal authenticated with a name of type UNKNOWN, however, will * only

Silly Java question

2005-12-25 Thread Jeff Bailey
Heya All, I'm just beating on the KerberosPrincipal class, and am trying to deal the comments given by people. The problem I'm having is that I have a name string and a type int. This is the comment at the top of my equals function: * From Section 7.2 of rfc1510: When comparing names, a