I think using 'other' instead of 'p' would make this easier to read, e.g.

if (refId == other.refId) {}

shows how you're comparing this to that. Alternatively, using "this" and "that" can work to clarify too, .e.g.

if (this.refId == that.refId) {}

Although, I personally like the former.