I do not think two distinct objects should be declared equal on the
basis that their identifying attribute is undefined.

John McNally

"Diethelm Guallar, Gonzalo" wrote:
> 
> > >     public boolean equals(BaseObject bo)
> > >    {
> > >         if (this == bo)
> > >         {
> > >             return true;
> > >         }
> > >         else
> > >         {
> > > +            if( this.getPrimaryKey() == null || bo.getPrimaryKey() ==
> null )
> > > +                return false;
> > > +            else
> > >                 return getPrimaryKey().equals(bo.getPrimaryKey());
> > >         }
> > >     }
> 
> Maybe this is nitpicking, but if both primary
> keys are null, maybe this should return true?
> If this is the case, this code should look
> closer to StringUtils.equals():
> 
>     public boolean equals(BaseObject bo)
>     {
>         if (bo == null)
>         {
>             return false;
>         }
>         else if (this == bo)
>         {
>             return true;
>         }
> 
>         Object k1 = this.getPrimaryKey;
>         Object k2 = bo.getPrimaryKey();
>         if (k1 == null)
>         {
>             return (k2 == null);
>         }
>         else if (k2 == null)
>         {
>             return false;
>         }
>         else
>         {
>             return (k1.equals(k2));
>         }
>     }
> 
> > Sean Legassick
> 
> --
> Gonzalo A. Diethelm
> [EMAIL PROTECTED]
> 
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to