🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8548

How to implement compare (equals) for javax.ejb.HomeHandle

#8548
From: Percy Christian
Date: Tue, 13 Mar 2001 16:35
45 lines
2401 bytes
I want to keep a HashSet of  Instances of a user class which contains a
javax.ejb.HomeHandle.
for that I created a HashSet like this.

private static final HashSet evaluators = new HashSet();

My class looks approx. like this

public class TradedQoSEvaluator implements java.io.Serializable
{
 protected HomeHandle homeHandle=null;

 public TradedQoSEvaluator(HomeHandle homeHandle)
 {
  this.homeHandle=homeHandle;
 }

I read that the HashSet (just as Set) uses the equals method to determine
whether or not an object is already in the HashSet.
So I overloaded the equals method of Object in my class with

 public boolean equals(Object otherObject)
 {
  if (this.getClass()==otherObject.getClass())
  {
   /** @todo We have to find out how we can compare two HomeHandles?  */
   //TradedQoSEvaluator other=(TradedQoSEvaluator)otherObject;
   //return homeHandle.equals(other.homeHandle);
   return true;
  }
  return false;
 }
}

Why is my method never called, neither when I invoke add() nor when I invoke
contains() is my method called.
Or put in other words, how can I prevent that two instances which both
contains a HomeHandle pointing to the same EJBHome are only added once to
the HashSet.
How can I find out if two HomeHandle point to the same EJBHome interface,
and how can I make my HashSet to reflect this.

Thanks for any help

Percy Christian
Technical Details
Message-ID: <3aae4b81$0$382$446d705c@news.skynet.be>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!skynet.be!poster!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,e5f959d065511fc8,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-13 08:34:04 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!skynet.be!poster!not-for-mail
Reply-To: "Percy Christian" <percy@manpowerandconsulting.com>
From: "Percy Christian" <percy@manpowerandconsulting.com>
Newsgroups: borland.public.jbuilder.java.language
Subject: How to implement compare (equals) for javax.ejb.HomeHandle
Date: Tue, 13 Mar 2001 17:35:05 +0100
Organization: M.P. & C. bvba
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Lines: 49
Message-ID: <3aae4b81$0$382$446d705c@news.skynet.be>
NNTP-Posting-Host: 194.78.220.243
X-Trace: 984501122 kaa.skynet.be 382 194.78.220.243
X-Complaints-To: abuse@skynet.be