We prefer to write:

  if (obj instanceof Attribute) {
    Attribute other = (Attribute)obj;
    ...
  }
  return false;

as this does both the null test and the type test at the same time.  It also permits us to compare a subclass according to our current semantics.