1) You can do it in a simple line to avoid nested ifs. Maybe easier to
read.
I guess compare with null can be skipped if you use instanceof later.
public class MyClass {
public boolean equals( Object obj ) {
return ( (obj instanceof MyClass) && ((MyClass) obj).id == this.id
));
}
}
2) But my classes are generated by the sourcegenerator. So I cannot change
it. I�m using my
generated class as data objects and I�m trying to put the bussiness logic
in a parallel classes.
But thinking in oop programming, comparison is responsability of data
object, isn�t it? What do you think about it?
______________________________________________
Ing. Gustavo Rafael Pistoia
CDA Inform�tica S.A.
TE: 4343-5200.
Int (6329) 4566.
"Richard Lawson"
<Richard.Lawson@St Para: [EMAIL PROTECTED]
eeves.NET> cc:
Asunto: Re: [castor-dev] Equals ?
14-02-02 05:06 PM
Por favor,
responda a
castor-dev
I override the Object.equals method compare ids.
something like:
public class MyClass {
public boolean equals( Object obj ) {
if ( obj == null || !(obj instanceof MyClass) ) return false;
else return ( ((MyClass) obj).id == this.id );
}
}
cheers - richard
-----Original Message-----
From: Gustavo Pistoia [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 11:36 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Equals ?
I wrote "org.exolab.castor.builder.equalsmethod=true" in my
castor.properties but
the classes generated has no equals method. What is going on? Or how can I
compare two objects?
Gracias, Thanks.
______________________________________________
Ing. Gustavo Rafael Pistoia
CDA Inform�tica S.A.
TE: 4343-5200.
Int (6329) 4566.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev