Skip to content

[FLINK-37788] Use Java 17 instanceof pattern matching in equals() method in Flink Core… #26552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (obj instanceof BooleanValue) {
return ((BooleanValue) obj).value == this.value;
if (obj instanceof BooleanValue other) {
return other.value == this.value;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public int hashCode() {

@Override
public boolean equals(final Object obj) {
if (obj instanceof ByteValue) {
return ((ByteValue) obj).value == this.value;
if (obj instanceof ByteValue other) {
return other.value == this.value;
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions flink-core/src/main/java/org/apache/flink/types/IntValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public int hashCode() {

@Override
public boolean equals(final Object obj) {
if (obj instanceof IntValue) {
return ((IntValue) obj).value == this.value;
if (obj instanceof IntValue other) {
return other.value == this.value;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public int hashCode() {
*/
@Override
public boolean equals(final Object obj) {
if (obj instanceof LongValue) {
return ((LongValue) obj).value == this.value;
if (obj instanceof LongValue other) {
return other.value == this.value;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public int hashCode() {

@Override
public boolean equals(final Object obj) {
if (obj instanceof ShortValue) {
return ((ShortValue) obj).value == this.value;
if (obj instanceof ShortValue other) {
return other.value == this.value;
}
return false;
}

// --------------------------------------------------------------------------------------------

@Override
Expand Down