Skip to content

Commit

Permalink
Use pattern matching for instanceof.
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Jun 28, 2022
1 parent 7c3ec83 commit 805a4ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2020, 2021 Red Hat Inc. and others.
* Copyright (c) 2020, 2022 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -167,8 +167,7 @@ public String getName() {

@Override
public boolean equals(Object obj) {
if (obj instanceof CargoProjectSourceContainer) {
CargoProjectSourceContainer loc = (CargoProjectSourceContainer) obj;
if (obj instanceof CargoProjectSourceContainer loc) {
return fProject == null ? loc.fProject == null : fProject.equals(loc.fProject);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2017, 2021 Red Hat Inc. and others.
* Copyright (c) 2017, 2022 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -265,10 +265,10 @@ private static Set<IWorkingSet> getWorkingSets(IResource resource) {
}

private static IResource toResource(Object o) {
if (o instanceof IResource) {
return (IResource) o;
} else if (o instanceof IAdaptable) {
return ((IAdaptable) o).getAdapter(IResource.class);
if (o instanceof IResource resource) {
return resource;
} else if (o instanceof IAdaptable adaptable) {
return adaptable.getAdapter(IResource.class);
} else {
return null;
}
Expand Down

0 comments on commit 805a4ba

Please sign in to comment.