Skip to content

Commit 44c9336

Browse files
authored
Simplify equality checks using Objects.equals in PostConstructAdapterFactoryTest (#2767)
1 parent 3e5ccb1 commit 44c9336

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java

+5-13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.gson.GsonBuilder;
2424
import java.util.Arrays;
2525
import java.util.List;
26+
import java.util.Objects;
2627
import javax.annotation.PostConstruct;
2728
import org.junit.Test;
2829

@@ -89,13 +90,8 @@ public boolean equals(Object o) {
8990
return false;
9091
}
9192
Sandwich other = (Sandwich) o;
92-
if (this.bread == null ? other.bread != null : !this.bread.equals(other.bread)) {
93-
return false;
94-
}
95-
if (this.cheese == null ? other.cheese != null : !this.cheese.equals(other.cheese)) {
96-
return false;
97-
}
98-
return true;
93+
94+
return Objects.equals(this.bread, other.bread) && Objects.equals(this.cheese, other.cheese);
9995
}
10096
}
10197

@@ -116,12 +112,8 @@ public boolean equals(Object o) {
116112
return false;
117113
}
118114
MultipleSandwiches other = (MultipleSandwiches) o;
119-
if (this.sandwiches == null
120-
? other.sandwiches != null
121-
: !this.sandwiches.equals(other.sandwiches)) {
122-
return false;
123-
}
124-
return true;
115+
116+
return Objects.equals(this.sandwiches, other.sandwiches);
125117
}
126118
}
127119
}

0 commit comments

Comments
 (0)