classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: Patch for EnumSyntax attributes in the print api


From: Mark Wielaard
Subject: Re: [cp-patches] FYI: Patch for EnumSyntax attributes in the print api
Date: Sun, 18 Dec 2005 23:10:17 +0100

Hi Wolfgang,

On Fri, 2005-12-16 at 20:22 +0100, Wolfgang Baer wrote:
> +  /**
> +   * Tests if the given object is equal to this object.
> +   * The objects are considered equal if both are of the same
> +   * Media subclass, not null and the values are equal.
> +   *
> +   * @param obj the object to test
> +   *
> +   * @return <code>true</code> if both objects are equal, 
> +   * <code>false</code> otherwise.
> +   */
> +  public boolean equals(Object obj)
> +  {
> +    if ((obj instanceof MediaName && this instanceof MediaName)
> +        || (obj instanceof MediaTray && this instanceof MediaTray)
> +        || (obj instanceof MediaSizeName && this instanceof MediaSizeName))
> +      {
> +        return ((Media) obj).getValue() == this.getValue();
> +      }
> +    
> +    return false;
> +  }

Wouldn't it be a bit more robust to write this as:

return (obj.getClass() == this.getClass()
        && ((Media) obj).getValue() == this.getValue());

Then you also accept any future subclasses.

Thanks a lot for all this print work, it is a huge job!

Cheers,

Mark

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]