Revision: Add helper method for comparison to Revision.NULL When Error Prone checks are enabled, comparing to Revision.NULL with the == or != operator results in a warning: [ReferenceEquality] Comparison using reference equality instead of value equality The NULL instance is used as a sentinel, so comparing with reference equality is correct. Rather than suppressing the warning at every place in the code, add a helper method that can be used, and suppress the warning only there. Note that the "ReferenceEquality" warning is Error Prone specific and suppressing it results in an "Unsupported @SuppressWarnings" warning. Change-Id: Ia50404f76f88c405b9298a645760c019384c92ff
diff --git a/java/com/google/gitiles/RevisionParser.java b/java/com/google/gitiles/RevisionParser.java index 89311a3..d530cdd 100644 --- a/java/com/google/gitiles/RevisionParser.java +++ b/java/com/google/gitiles/RevisionParser.java
@@ -225,7 +225,7 @@ if (!cache.isVisible(repo, walk, access, id)) { return false; } - if (result.getOldRevision() != null && result.getOldRevision() != Revision.NULL) { + if (result.getOldRevision() != null && !Revision.isNull(result.getOldRevision())) { return cache.isVisible(repo, walk, access, result.getOldRevision().getId(), id); } return true;