Merge pull request #227 from Project-Cepi/update-option-equals

Equals & hashcode overrides for UpdateOption
This commit is contained in:
TheMode 2021-04-07 03:41:13 +02:00 committed by GitHub
commit 64479b1409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,8 @@ package net.minestom.server.utils.time;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class UpdateOption { public class UpdateOption {
private final long value; private final long value;
@ -20,4 +22,17 @@ public class UpdateOption {
public TimeUnit getTimeUnit() { public TimeUnit getTimeUnit() {
return timeUnit; return timeUnit;
} }
@Override
public int hashCode() {
return Objects.hash(value, timeUnit);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UpdateOption updateOption = (UpdateOption) o;
return Objects.equals(value, updateOption.value) && Objects.equals(timeUnit, updateOption.timeUnit);
}
} }