package org.jenkinsci.plugins.p4.scm;

import jenkins.scm.api.SCMRevision;
import org.jenkinsci.plugins.p4.changes.P4Ref;

import java.util.Objects;

public class P4Revision extends SCMRevision {
	private final P4Ref ref;

	P4Revision(P4Head branch, P4Ref ref) {
		super(branch);
		this.ref = ref;
	}

	public P4Ref getRef() {
		return ref;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		P4Revision that = (P4Revision) o;
		boolean c = ref == that.ref;
		boolean h = getHead().equals(that.getHead());
		return c && h;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		return Objects.hashCode(ref);
	}

	@Override
	public String toString() {
		return ref.toString();
	}
}

@@ -578,20 +578,24 @@
  ref
- == 
+.equals(
 that.ref
 ;%0A%09%09
@@ -590,16 +590,17 @@
 that.ref
+)
 ;%0A%09%09bool
@@ -797,24 +797,72 @@
 oString() %7B%0A
+%09%09if (ref == null) %7B%0A%09%09%09return %22undefined%22;%0A%09%09%7D%0A
 %09%09return ref

Fix equals used in comparable check and null check.