mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[cscore, wpilibj] Use pattern matching in equals overrides (#7003)
Fixes https://errorprone.info/bugpattern/EqualsGetClass
This commit is contained in:
@@ -117,12 +117,12 @@ public class Color {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Color color = (Color) other;
|
||||
return Double.compare(color.red, red) == 0
|
||||
return other instanceof Color color
|
||||
&& Double.compare(color.red, red) == 0
|
||||
&& Double.compare(color.green, green) == 0
|
||||
&& Double.compare(color.blue, blue) == 0;
|
||||
}
|
||||
|
||||
@@ -69,12 +69,14 @@ public class Color8Bit {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Color8Bit color8Bit = (Color8Bit) other;
|
||||
return red == color8Bit.red && green == color8Bit.green && blue == color8Bit.blue;
|
||||
return other instanceof Color8Bit color8Bit
|
||||
&& red == color8Bit.red
|
||||
&& green == color8Bit.green
|
||||
&& blue == color8Bit.blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user