diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-11-30 15:02:56 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-11-30 17:42:02 +0100 |
commit | 08dbeeee650d4792b6aaabb109ccd9504d282804 (patch) | |
tree | 89725d498247db5939ab1e2e76af391f8e041c9c /server | |
parent | cd707d4f0d8605d6d849288becd6a62aa1669add (diff) | |
download | sonarqube-08dbeeee650d4792b6aaabb109ccd9504d282804.tar.gz sonarqube-08dbeeee650d4792b6aaabb109ccd9504d282804.zip |
add equals and hashcode to Period class
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/computation/period/Period.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/period/Period.java b/server/sonar-server/src/main/java/org/sonar/server/computation/period/Period.java index dc4fdf1d8de..86e7c5e9716 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/period/Period.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/period/Period.java @@ -20,11 +20,12 @@ package org.sonar.server.computation.period; -import com.google.common.base.Objects; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; +import static com.google.common.base.Objects.toStringHelper; +import static java.util.Objects.hash; import static java.util.Objects.requireNonNull; @Immutable @@ -77,8 +78,29 @@ public class Period { } @Override + public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Period period = (Period) o; + return index == period.index + && snapshotDate == period.snapshotDate + && snapshotId == period.snapshotId + && mode.equals(period.mode) + && java.util.Objects.equals(modeParameter, period.modeParameter); + } + + @Override + public int hashCode() { + return hash(index, mode, modeParameter, snapshotDate, snapshotId); + } + + @Override public String toString() { - return Objects.toStringHelper(this) + return toStringHelper(this) .add("index", index) .add("mode", mode) .add("modeParameter", modeParameter) |