From 805a4baca412f9d32a82b5ca66a15d246c6a01d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 28 Jun 2022 23:26:20 +0300 Subject: [PATCH] Use pattern matching for instanceof. --- .../sourcelookup/CargoProjectSourceContainer.java | 5 ++--- .../wizards/newproject/NewCargoProjectWizard.java | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/org.eclipse.corrosion/src/org/eclipse/corrosion/sourcelookup/CargoProjectSourceContainer.java b/org.eclipse.corrosion/src/org/eclipse/corrosion/sourcelookup/CargoProjectSourceContainer.java index 65879bc..4663c7c 100644 --- a/org.eclipse.corrosion/src/org/eclipse/corrosion/sourcelookup/CargoProjectSourceContainer.java +++ b/org.eclipse.corrosion/src/org/eclipse/corrosion/sourcelookup/CargoProjectSourceContainer.java @@ -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 @@ -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; diff --git a/org.eclipse.corrosion/src/org/eclipse/corrosion/wizards/newproject/NewCargoProjectWizard.java b/org.eclipse.corrosion/src/org/eclipse/corrosion/wizards/newproject/NewCargoProjectWizard.java index 3887f5f..351f5c2 100644 --- a/org.eclipse.corrosion/src/org/eclipse/corrosion/wizards/newproject/NewCargoProjectWizard.java +++ b/org.eclipse.corrosion/src/org/eclipse/corrosion/wizards/newproject/NewCargoProjectWizard.java @@ -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 @@ -265,10 +265,10 @@ private static Set 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; }