diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/NameVersionDescriptor.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/NameVersionDescriptor.java index 4fc0bf869a..a0e815e029 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/NameVersionDescriptor.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/NameVersionDescriptor.java @@ -78,8 +78,7 @@ public NameVersionDescriptor(String id, String version, String type) { @Override public boolean equals(Object obj) { - if (obj instanceof NameVersionDescriptor) { - NameVersionDescriptor iud = (NameVersionDescriptor) obj; + if (obj instanceof NameVersionDescriptor iud) { if (fId.equals(iud.fId)) { return (fVersion != null && fVersion.equals(iud.fVersion)) || (fVersion == null && iud.fVersion == null); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DependencyManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DependencyManager.java index 03442f8b2a..a1fdccd9eb 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DependencyManager.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DependencyManager.java @@ -206,8 +206,7 @@ public static Set findRequirementsClosure(Collection entry : headers) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/ExportPackageAnnotationProcessor.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/ExportPackageAnnotationProcessor.java index 880f9e3b5f..eb57e4869f 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/ExportPackageAnnotationProcessor.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/ExportPackageAnnotationProcessor.java @@ -58,8 +58,7 @@ public void apply(IBaseModel model) { } private static ExportPackageObject getExportPackage(IBaseModel model, String packageName) { - if (model instanceof IBundlePluginModelBase) { - IBundlePluginModelBase pluginModel = (IBundlePluginModelBase) model; + if (model instanceof IBundlePluginModelBase pluginModel) { IBundleModel bundleModel = pluginModel.getBundleModel(); IBundle bundle = bundleModel.getBundle(); IManifestHeader header = bundle.getManifestHeader(Constants.EXPORT_PACKAGE); @@ -67,8 +66,7 @@ private static ExportPackageObject getExportPackage(IBaseModel model, String pac bundle.setHeader(Constants.EXPORT_PACKAGE, packageName); header = bundle.getManifestHeader(Constants.EXPORT_PACKAGE); } - if (header instanceof ExportPackageHeader) { - ExportPackageHeader exportPackageHeader = (ExportPackageHeader) header; + if (header instanceof ExportPackageHeader exportPackageHeader) { ExportPackageObject packageObject = exportPackageHeader.getPackage(packageName); if (packageObject == null) { return exportPackageHeader.addPackage(packageName); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/OSGiAnnotationProcessor.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/OSGiAnnotationProcessor.java index 371aef340b..5e5812592b 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/OSGiAnnotationProcessor.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/annotations/OSGiAnnotationProcessor.java @@ -67,8 +67,7 @@ static Optional stringValue(Expression expression) { */ static Stream expressions(Expression expression) { Expression unwrap = value(expression).orElse(expression); - if (unwrap instanceof ArrayInitializer) { - ArrayInitializer arrayInitializer = (ArrayInitializer) unwrap; + if (unwrap instanceof ArrayInitializer arrayInitializer) { return arrayInitializer.expressions().stream().filter(Expression.class::isInstance) .map(Expression.class::cast); } @@ -98,11 +97,9 @@ static Optional value(Expression annotation) { * optional if no such member exits. */ static Optional member(Expression annotation, String memberName) { - if (annotation instanceof NormalAnnotation) { - NormalAnnotation normalAnnotation = (NormalAnnotation) annotation; + if (annotation instanceof NormalAnnotation normalAnnotation) { for (Object value : normalAnnotation.values()) { - if (value instanceof MemberValuePair) { - MemberValuePair pair = (MemberValuePair) value; + if (value instanceof MemberValuePair pair) { SimpleName name = pair.getName(); if (name != null && name.toString().equals(memberName)) { return Optional.ofNullable(pair.getValue()); @@ -110,8 +107,7 @@ static Optional member(Expression annotation, String memberName) { } } } - if (annotation instanceof SingleMemberAnnotation && "value".equals(memberName)) { //$NON-NLS-1$ - SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation; + if (annotation instanceof SingleMemberAnnotation singleMemberAnnotation && "value".equals(memberName)) { //$NON-NLS-1$ return Optional.ofNullable(singleMemberAnnotation.getValue()); } return Optional.empty(); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java index be727a0923..d62d816b27 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java @@ -159,8 +159,7 @@ private static boolean hasRelevantDelta(IResourceDelta delta) throws CoreExcepti @Override public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); - if (resource instanceof IFile) { - IFile file = (IFile) resource; + if (resource instanceof IFile file) { String name = file.getName(); if (name.endsWith(CLASS_EXTENSION) || file.getName().equals(BndProject.INSTRUCTIONS_FILE) || name.equals(ICoreConstants.MANIFEST_FILENAME)) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndProjectManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndProjectManager.java index 740bdb1716..38720f40d8 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndProjectManager.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndProjectManager.java @@ -132,8 +132,7 @@ public static List getClasspathEntries(Project project, IWorksp @SuppressWarnings("deprecation") IContainer[] containers = root.findContainersForLocation(IPath.fromOSString(base.getAbsolutePath())); for (IContainer container : containers) { - if (container instanceof IProject) { - IProject p = (IProject) container; + if (container instanceof IProject p) { entries.add(JavaCore.newProjectEntry(p.getFullPath())); } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndResourceChangeListener.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndResourceChangeListener.java index ea5ebd793f..bcb93f3537 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndResourceChangeListener.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndResourceChangeListener.java @@ -49,8 +49,7 @@ public void resourceChanged(IResourceChangeEvent event) { @Override public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); - if (resource instanceof IFile) { - IFile file = (IFile) resource; + if (resource instanceof IFile file) { if (BndProject.INSTRUCTIONS_FILE.equals(file.getName()) && BndProject.isBndProject(file.getProject())) { updateProjects.add(file.getProject()); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java index 64e5895566..5be80fd74f 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java @@ -119,10 +119,9 @@ static class BuildProblem { @Override public boolean equals(Object obj) { - if (!(obj instanceof BuildProblem)) { + if (!(obj instanceof BuildProblem bp)) { return false; } - BuildProblem bp = (BuildProblem) obj; if (!fEntryName.equals(bp.fEntryName)) { return false; } @@ -1235,10 +1234,9 @@ private void reportErrors(BuildModel bm) { } private int getLineNumber(IBuildEntry ibe, String tokenString) { - if (!(ibe instanceof BuildEntry)) { + if (!(ibe instanceof BuildEntry be)) { return 0; } - BuildEntry be = (BuildEntry) ibe; IDocument doc = ((BuildModel) be.getModel()).getDocument(); try { int buildEntryLineNumber = doc.getLineOfOffset(be.getOffset()) + 1; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java index 2f5c39f6a7..c43c8cdf72 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java @@ -237,8 +237,7 @@ private void validateExportPackages() { IHeader header = getHeader(Constants.EXPORT_PACKAGE); // check for missing exported packages - if (fModel instanceof IBundlePluginModelBase) { - IBundlePluginModelBase bundleModel = (IBundlePluginModelBase) fModel; + if (fModel instanceof IBundlePluginModelBase bundleModel) { IBundle bundle = bundleModel.getBundleModel().getBundle(); IManifestHeader bundleClasspathheader = bundle.getManifestHeader(Constants.BUNDLE_CLASSPATH); @@ -251,8 +250,7 @@ private void validateExportPackages() { if (ManifestUtils.isImmediateRoot(root)) { IJavaElement[] javaElements = root.getChildren(); for (int j = 0; j < javaElements.length; j++) { - if (javaElements[j] instanceof IPackageFragment) { - IPackageFragment fragment = (IPackageFragment) javaElements[j]; + if (javaElements[j] instanceof IPackageFragment fragment) { String name = fragment.getElementName(); if (name.length() == 0) { continue; @@ -1728,12 +1726,11 @@ private void validateBundleLocalization() { } IResource res = PDEProject.getBundleRoot(fProject).findMember(location); - if (res == null || !(res instanceof IContainer)) { + if (res == null || !(res instanceof IContainer folder)) { VirtualMarker marker = report(PDECoreMessages.BundleErrorReporter_localization_folder_not_exist, header.getLineNumber(), CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_RESOURCE), PDEMarkerFactory.CAT_OTHER); addMarkerAttribute(marker, PDEMarkerFactory.compilerKey, CompilerFlags.P_UNKNOWN_RESOURCE); return; } - IContainer folder = (IContainer) res; try { IResource[] children = folder.members(); for (int i = 0; i < children.length; i++) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ElementOccurenceChecker.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ElementOccurenceChecker.java index 954cf7e863..fea59ebbb3 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ElementOccurenceChecker.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ElementOccurenceChecker.java @@ -281,24 +281,20 @@ private static void updateChoiceElementChildren(ISchemaCompositor compositor, Ha } private static void processObjectMax(ISchemaObject schemaObject, HashSet elementSet, HashMap siblings, int multiplicityTracker, Element element) { - if (schemaObject instanceof ISchemaElement) { - ISchemaElement schemaElement = (ISchemaElement) schemaObject; + if (schemaObject instanceof ISchemaElement schemaElement) { Element childElement = findChildElement(element, schemaElement.getName()); if (childElement != null) { processElementMax(schemaElement, elementSet, siblings, multiplicityTracker, childElement); } - } else if (schemaObject instanceof ISchemaCompositor) { - ISchemaCompositor sCompositor = (ISchemaCompositor) schemaObject; + } else if (schemaObject instanceof ISchemaCompositor sCompositor) { processCompositorMax(sCompositor, elementSet, siblings, multiplicityTracker, element); } } private static void processObjectMin(ISchemaObject schemaObject, HashSet elementSet, HashMap siblings, int multiplicityTracker) { - if (schemaObject instanceof ISchemaElement) { - ISchemaElement schemaElement = (ISchemaElement) schemaObject; + if (schemaObject instanceof ISchemaElement schemaElement) { processElementMin(schemaElement, elementSet, siblings, multiplicityTracker); - } else if (schemaObject instanceof ISchemaCompositor) { - ISchemaCompositor sCompositor = (ISchemaCompositor) schemaObject; + } else if (schemaObject instanceof ISchemaCompositor sCompositor) { processCompositorMin(sCompositor, elementSet, siblings, multiplicityTracker); } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java index 92c27ebaa2..b87f0f54a4 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java @@ -69,9 +69,8 @@ public boolean visit(IResourceDelta delta) { return true; } - if (resource instanceof IFile) { + if (resource instanceof IFile candidate) { // see if this is it - IFile candidate = (IFile) resource; if (isSchemaFile(candidate)) { // That's it, but only check it if it has been added or changed if (delta.getKind() != IResourceDelta.REMOVED) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java index 9486088209..7c02ab3979 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java @@ -276,8 +276,7 @@ private void validateInternalExtensionAttribute(Element element, ISchemaElement return; } - if (schemaElement instanceof ISchemaRootElement) { - ISchemaRootElement rootElement = (ISchemaRootElement) schemaElement; + if (schemaElement instanceof ISchemaRootElement rootElement) { String epid = schemaElement.getSchema().getPluginId(); if (fModel == null || fModel.getPluginBase() == null) { return; @@ -331,8 +330,7 @@ private void validateMaxElementMult(Element element, ISchemaElement schemaElemen } private void computeAllowedElements(ISchemaType type, HashSet elementSet) { - if (type instanceof ISchemaComplexType) { - ISchemaComplexType complexType = (ISchemaComplexType) type; + if (type instanceof ISchemaComplexType complexType) { ISchemaCompositor compositor = complexType.getCompositor(); if (compositor != null) { computeAllowedElements(compositor, elementSet); @@ -350,8 +348,7 @@ private void computeAllowedElements(ISchemaType type, HashSet elementSet private void computeAllowedElements(ISchemaCompositor compositor, HashSet elementSet) { ISchemaObject[] children = compositor.getChildren(); for (ISchemaObject child : children) { - if (child instanceof ISchemaObjectReference) { - ISchemaObjectReference ref = (ISchemaObjectReference) child; + if (child instanceof ISchemaObjectReference ref) { ISchemaElement refElement = (ISchemaElement) ref.getReferencedObject(); if (refElement != null) { elementSet.add(refElement.getName()); @@ -664,8 +661,7 @@ protected void validateRestrictionAttribute(Element element, Attr attr, ISchemaR Object[] children = restriction.getChildren(); String value = attr.getValue(); for (Object child : children) { - if (child instanceof ISchemaEnumeration) { - ISchemaEnumeration enumeration = (ISchemaEnumeration) child; + if (child instanceof ISchemaEnumeration enumeration) { if (enumeration.getName().equals(value)) { return; } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureConsistencyChecker.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureConsistencyChecker.java index 752e2562c8..999275b3ee 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureConsistencyChecker.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureConsistencyChecker.java @@ -48,9 +48,8 @@ public DeltaVisitor(IProgressMonitor monitor) { public boolean visit(IResourceDelta delta) { IResource resource = delta.getResource(); - if (resource instanceof IProject) { + if (resource instanceof IProject project) { // Only check projects with feature nature - IProject project = (IProject) resource; try { return (project.hasNature(PDE.FEATURE_NATURE)); } catch (CoreException e) { @@ -58,9 +57,8 @@ public boolean visit(IResourceDelta delta) { return false; } } - if (resource instanceof IFile) { + if (resource instanceof IFile candidate) { // see if this is it - IFile candidate = (IFile) resource; if (isManifestFile(candidate)) { // That's it, but only check it if it has been added or changed if (delta.getKind() != IResourceDelta.REMOVED) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java index 9ce5133f2f..a30e3443cc 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/FeatureErrorReporter.java @@ -448,8 +448,7 @@ private void validateUnpack(Element parent) { return; } - if (pModel instanceof IBundlePluginModel) { - IBundlePluginModel bModel = (IBundlePluginModel) pModel; + if (pModel instanceof IBundlePluginModel bModel) { IManifestHeader header = bModel.getBundleModel().getBundle().getManifestHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE); if (header != null) { String value = header.getValue(); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SchemaErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SchemaErrorReporter.java index 24ff38b6eb..3042e37ebe 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SchemaErrorReporter.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SchemaErrorReporter.java @@ -106,8 +106,7 @@ public void validate(IProgressMonitor monitor) { NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); - if (child instanceof Element) { - Element childElement = (Element) child; + if (child instanceof Element childElement) { String name = childElement.getNodeName(); if (name != null && name.equals(ELEMENT)) { String value = childElement.getAttribute(ATTR_NAME); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SourceEntryErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SourceEntryErrorReporter.java index 3befbcbd58..c23058f57e 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SourceEntryErrorReporter.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/SourceEntryErrorReporter.java @@ -209,8 +209,7 @@ public String toString() { @Override public boolean equals(Object obj) { - if (obj instanceof EncodingEntry) { - EncodingEntry other = (EncodingEntry) obj; + if (obj instanceof EncodingEntry other) { return other.fEncoding.equals(fEncoding) && other.fResource.equals(fResource); } return false; @@ -412,8 +411,7 @@ public void initialize(List sourceEntries, List output private IPath getPath(Object entry) { IPath path = null; - if (entry instanceof IClasspathEntry) { - IClasspathEntry cpes = (IClasspathEntry) entry; + if (entry instanceof IClasspathEntry cpes) { path = cpes.getPath(); } else if (entry instanceof IPath) { path = (IPath) entry; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java index e607025c68..f8afd55866 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java @@ -45,9 +45,8 @@ public DeltaVisitor(IProgressMonitor monitor) { public boolean visit(IResourceDelta delta) { IResource resource = delta.getResource(); - if (resource instanceof IProject) { + if (resource instanceof IProject project) { // Only check projects with feature nature - IProject project = (IProject) resource; try { return (project.hasNature(PDE.SITE_NATURE)); } catch (CoreException e) { @@ -55,9 +54,8 @@ public boolean visit(IResourceDelta delta) { return false; } } - if (resource instanceof IFile) { + if (resource instanceof IFile candidate) { // see if this is it - IFile candidate = (IFile) resource; if (candidate.getName().equals("site.xml")) { //$NON-NLS-1$ // That's it, but only check it if it has been added or changed if (delta.getKind() != IResourceDelta.REMOVED) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java index 42383d10cb..9d809e2e6e 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java @@ -96,14 +96,12 @@ public void dispose() { @Override public void save() { - if (fBundleModel != null && fBundleModel instanceof IEditableModel) { - IEditableModel emodel = (IEditableModel) fBundleModel; + if (fBundleModel != null && fBundleModel instanceof IEditableModel emodel) { if (emodel.isDirty()) { emodel.save(); } } - if (fExtensionsModel != null && fExtensionsModel instanceof IEditableModel) { - IEditableModel emodel = (IEditableModel) fExtensionsModel; + if (fExtensionsModel != null && fExtensionsModel instanceof IEditableModel emodel) { if (emodel.isDirty()) { emodel.save(); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/WorkspaceExportHelper.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/WorkspaceExportHelper.java index 7efb6e2c0f..9f774ce600 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/WorkspaceExportHelper.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/WorkspaceExportHelper.java @@ -187,8 +187,7 @@ private IProject[] getExportedWorkspaceProjects(Object[] exportedItems) throws C if (project.exists()) { projects.add(project); } - } else if (exportedItem instanceof IFeatureModel) { - IFeatureModel feature = (IFeatureModel) exportedItem; + } else if (exportedItem instanceof IFeatureModel feature) { IFeaturePlugin[] plugins = feature.getFeature().getPlugins(); for (IFeaturePlugin plugin : plugins) { IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(plugin.getId()); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ImportObject.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ImportObject.java index 20dcfab84d..a3a4296e74 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ImportObject.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ImportObject.java @@ -40,8 +40,7 @@ public IPluginImport getImport() { @Override public boolean equals(Object object) { - if (object instanceof ImportObject) { - ImportObject io = (ImportObject) object; + if (object instanceof ImportObject io) { if (iimport.equals(io.getImport())) { return true; } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginAttribute.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginAttribute.java index 16cabc8f08..366f996432 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginAttribute.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginAttribute.java @@ -53,8 +53,7 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (obj instanceof IPluginAttribute) { - IPluginAttribute target = (IPluginAttribute) obj; + if (obj instanceof IPluginAttribute target) { if (target.getModel().equals(getModel())) { return false; } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginElement.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginElement.java index 05a3d6dbf2..3dfc1ff055 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginElement.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginElement.java @@ -77,8 +77,7 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (obj instanceof IPluginElement) { - IPluginElement target = (IPluginElement) obj; + if (obj instanceof IPluginElement target) { // Equivalent models must return false to get proper source range selection, see bug 267954. if (target.getModel().equals(getModel())) { return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtension.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtension.java index 5076cbb969..0f7bd576a5 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtension.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtension.java @@ -101,9 +101,7 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (obj instanceof IPluginExtension) { - IPluginExtension target = (IPluginExtension) obj; - + if (obj instanceof IPluginExtension target) { // comparing the model is a little complicated since we need to allow text and non-text models representing the same file if (target.getModel().getClass() == getModel().getClass()) { if (!target.getModel().equals(getModel())) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtensionPoint.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtensionPoint.java index f35427135e..5dffe03133 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtensionPoint.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginExtensionPoint.java @@ -84,8 +84,7 @@ public boolean equals(Object obj) { if (obj == this) { return true; } - if (obj instanceof IPluginExtensionPoint) { - IPluginExtensionPoint target = (IPluginExtensionPoint) obj; + if (obj instanceof IPluginExtensionPoint target) { // Objects from the same model must be // binary equal if (target.getModel().equals(getModel())) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginImport.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginImport.java index f64513a41b..d20d1d9f97 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginImport.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginImport.java @@ -129,8 +129,7 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (obj instanceof IPluginImport) { - IPluginImport target = (IPluginImport) obj; + if (obj instanceof IPluginImport target) { // Objects from the same model must be // binary equal if (target.getModel().equals(getModel())) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginObject.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginObject.java index bedcd4a8b2..8ad3bca25e 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginObject.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginObject.java @@ -100,8 +100,7 @@ protected void fireStructureChanged(IPluginObject[] children, int changeType) { protected void fireModelChanged(IModelChangedEvent e) { IModel model = getModel(); - if (model.isEditable() && model instanceof IModelChangeProvider) { - IModelChangeProvider provider = (IModelChangeProvider) model; + if (model.isEditable() && model instanceof IModelChangeProvider provider) { provider.fireModelChanged(e); } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginParent.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginParent.java index 2eae7766b5..6c15393bc1 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginParent.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginParent.java @@ -66,8 +66,7 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (obj instanceof IPluginParent) { - IPluginParent target = (IPluginParent) obj; + if (obj instanceof IPluginParent target) { if (target.getChildCount() != getChildCount()) { return false; } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/ProductModel.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/ProductModel.java index 14d6363dcf..fc83c9866b 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/ProductModel.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/ProductModel.java @@ -85,8 +85,7 @@ public void load(InputStream stream, boolean outOfSync) throws CoreException { processDocument(handler.getDocument()); String copyright = chandler.getCopyright(); if (copyright != null) { - if (fProduct instanceof Product) { - Product product = (Product) fProduct; + if (fProduct instanceof Product product) { product.setCopyright(copyright); } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/RepositoryInfo.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/RepositoryInfo.java index 103e15bb2d..9df8e8ba14 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/RepositoryInfo.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/product/RepositoryInfo.java @@ -96,10 +96,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof RepositoryInfo)) { + if (!(obj instanceof RepositoryInfo other)) { return false; } - RepositoryInfo other = (RepositoryInfo) obj; return Objects.equals(fURL, other.fURL); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/BundleClasspathSpecification.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/BundleClasspathSpecification.java index a4986b4952..281ab40501 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/BundleClasspathSpecification.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/BundleClasspathSpecification.java @@ -57,8 +57,7 @@ public IPath getLibrary() { @Override public boolean equals(Object obj) { - if (obj instanceof IBundleClasspathEntry) { - IBundleClasspathEntry spec = (IBundleClasspathEntry) obj; + if (obj instanceof IBundleClasspathEntry spec) { return equalOrNull(getSourcePath(), spec.getSourcePath()) && equalOrNull(getBinaryPath(), spec.getBinaryPath()) && equalOrNull(getLibrary(), spec.getLibrary()); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/PackageExportDescription.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/PackageExportDescription.java index 097bb1e5d1..39c333440c 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/PackageExportDescription.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/PackageExportDescription.java @@ -58,8 +58,7 @@ public String getName() { @Override public boolean equals(Object obj) { - if (obj instanceof PackageExportDescription) { - PackageExportDescription spec = (PackageExportDescription) obj; + if (obj instanceof PackageExportDescription spec) { return getName().equals(spec.getName()) && isApi() == spec.isApi() && equalOrNull(getVersion(), spec.getVersion()) && equalOrNull(getFriends(), spec.getFriends()); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/ProjectModifyOperation.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/ProjectModifyOperation.java index 928056cdfd..6f2538a123 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/ProjectModifyOperation.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/ProjectModifyOperation.java @@ -507,8 +507,7 @@ private void configureManifest(IBundleProjectDescription description, IBundlePro } // manifest version - if (fModel instanceof IBundlePluginModelBase) { - IBundlePluginModelBase bmodel = ((IBundlePluginModelBase) fModel); + if (fModel instanceof IBundlePluginModelBase bmodel) { // Target version is not persisted and does not make the model dirty. // It is only used by the new project wizard to determine which templates are available. ((IBundlePluginBase) bmodel.getPluginBase()).setTargetVersion(targetVersion); @@ -517,9 +516,8 @@ private void configureManifest(IBundleProjectDescription description, IBundlePro bmodel.getBundleModel().getBundle().setHeader(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ } } - if (pluginBase instanceof IFragment) { + if (pluginBase instanceof IFragment fragment) { // host specification - IFragment fragment = (IFragment) pluginBase; IHostDescription host = description.getHost(); if (!isEqual(host, before.getHost())) { fragment.setPluginId(host.getName()); @@ -688,8 +686,7 @@ private void configureManifest(IBundleProjectDescription description, IBundlePro } // if the bundle model has been made dirty, ensure that propagates back to the root model IBundleModel bundleModel = bundle.getModel(); - if (bundleModel instanceof WorkspaceBundleModel) { - WorkspaceBundleModel wbm = (WorkspaceBundleModel) bundleModel; + if (bundleModel instanceof WorkspaceBundleModel wbm) { if (wbm.isDirty()) { fModel.setDirty(true); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/RequirementSpecification.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/RequirementSpecification.java index 17104c0b75..baa13e4041 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/RequirementSpecification.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/RequirementSpecification.java @@ -54,8 +54,7 @@ public boolean isExported() { @Override public boolean equals(Object obj) { - if (obj instanceof RequirementSpecification) { - RequirementSpecification spec = (RequirementSpecification) obj; + if (obj instanceof RequirementSpecification spec) { return getName().equals(spec.getName()) && isExported() == spec.isExported() && isOptional() == spec.isOptional() && equalOrNull(getVersionRange(), spec.getVersionRange()); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/ChoiceRestriction.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/ChoiceRestriction.java index bfa0d752d4..58bbe3d216 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/ChoiceRestriction.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/ChoiceRestriction.java @@ -115,8 +115,7 @@ public String toString() { for (int i = 0; i < children.size(); i++) { Object child = children.get(i); - if (child instanceof ISchemaEnumeration) { - ISchemaEnumeration enumeration = (ISchemaEnumeration) child; + if (child instanceof ISchemaEnumeration enumeration) { if (i > 0) { buffer.append(", "); //$NON-NLS-1$ } @@ -131,8 +130,7 @@ public void write(String indent, PrintWriter writer) { writer.println(indent + ""); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < children.size(); i++) { Object child = children.get(i); - if (child instanceof ISchemaEnumeration) { - ISchemaEnumeration enumeration = (ISchemaEnumeration) child; + if (child instanceof ISchemaEnumeration enumeration) { enumeration.write(indent + Schema.INDENT, writer); } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/Schema.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/Schema.java index c8cb30f31f..260b9ae580 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/Schema.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/Schema.java @@ -164,8 +164,7 @@ private void collectElements(ISchemaCompositor compositor, Vector result for (Object child : children) { if (child instanceof ISchemaCompositor) { collectElements((ISchemaCompositor) child, result); - } else if (child instanceof ISchemaObjectReference) { - ISchemaObjectReference ref = (ISchemaObjectReference) child; + } else if (child instanceof ISchemaObjectReference ref) { Object referenced = ref.getReferencedObject(); if (referenced instanceof ISchemaElement) { result.addElement(referenced); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaCompositor.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaCompositor.java index 62a692ced4..27c95f0385 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaCompositor.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaCompositor.java @@ -158,8 +158,7 @@ public void setKind(int kind) { public void updateReferencesFor(ISchemaElement element, int kind) { for (int i = children.size() - 1; i >= 0; i--) { Object child = children.elementAt(i); - if (child instanceof SchemaElementReference) { - SchemaElementReference ref = (SchemaElementReference) child; + if (child instanceof SchemaElementReference ref) { String refName = ref.getReferenceName(); switch (kind) { case ISchema.REFRESH_ADD : diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaElement.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaElement.java index 0bbd0b56e9..cc329da712 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaElement.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaElement.java @@ -153,8 +153,7 @@ public String getDTDRepresentation(boolean addLinks) { if (type == null) { text += "EMPTY"; //$NON-NLS-1$ } else { - if (type instanceof ISchemaComplexType) { - ISchemaComplexType complexType = (ISchemaComplexType) type; + if (type instanceof ISchemaComplexType complexType) { ISchemaCompositor compositor = complexType.getCompositor(); if (compositor != null) { text += calculateChildRepresentation(compositor, addLinks); @@ -220,8 +219,7 @@ public void setParent(ISchemaObject parent) { super.setParent(parent); if (type != null) { type.setSchema(getSchema()); - if (type instanceof ISchemaComplexType) { - ISchemaComplexType ctype = (ISchemaComplexType) type; + if (type instanceof ISchemaComplexType ctype) { ISchemaCompositor comp = ctype.getCompositor(); if (comp != null) { comp.setParent(this); @@ -318,8 +316,7 @@ public void write(String indent, PrintWriter writer) { writer.println(indent2 + ""); //$NON-NLS-1$ } - if (type instanceof SchemaComplexType) { - SchemaComplexType complexType = (SchemaComplexType) type; + if (type instanceof SchemaComplexType complexType) { complexType.write(indent2, writer); } writer.println(indent + ""); //$NON-NLS-1$ diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaInclude.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaInclude.java index 3f0c6ff4be..9f86b258b3 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaInclude.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaInclude.java @@ -126,8 +126,7 @@ public void dispose() { @Override public boolean equals(Object obj) { - if (obj instanceof ISchemaInclude) { - ISchemaInclude other = (ISchemaInclude) obj; + if (obj instanceof ISchemaInclude other) { if (fLocation != null) { return fLocation.equals(other.getLocation()); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/DirectoryBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/DirectoryBundleContainer.java index 1854115a4c..3045aeb36d 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/DirectoryBundleContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/DirectoryBundleContainer.java @@ -123,8 +123,7 @@ protected File getDirectory() throws CoreException { @Override public boolean equals(Object o) { - if (o instanceof DirectoryBundleContainer) { - DirectoryBundleContainer dbc = (DirectoryBundleContainer) o; + if (o instanceof DirectoryBundleContainer dbc) { return fPath.equals(dbc.fPath); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ExternalFileTargetHandle.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ExternalFileTargetHandle.java index 493ff3c5c7..dc0b429cb4 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ExternalFileTargetHandle.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ExternalFileTargetHandle.java @@ -105,8 +105,7 @@ public String getMemento() throws CoreException { @Override public boolean equals(Object obj) { - if (obj instanceof ExternalFileTargetHandle) { - ExternalFileTargetHandle target = (ExternalFileTargetHandle) obj; + if (obj instanceof ExternalFileTargetHandle target) { return target.getLocation().equals(fURI); } return super.equals(obj); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/FeatureBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/FeatureBundleContainer.java index 9c9ef70aa1..2e4ec4a7ad 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/FeatureBundleContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/FeatureBundleContainer.java @@ -200,8 +200,7 @@ protected TargetFeature[] resolveFeatures(ITargetDefinition definition, IProgres @Override public boolean equals(Object o) { - if (o instanceof FeatureBundleContainer) { - FeatureBundleContainer fbc = (FeatureBundleContainer) o; + if (o instanceof FeatureBundleContainer fbc) { return fHome.equals(fbc.fHome) && fId.equals(fbc.fId) && isNullOrEqual(fVersion, fVersion); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java index e5dc6bd0fd..e128df397e 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java @@ -505,10 +505,9 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (!(obj instanceof IUBundleContainer)) { + if (!(obj instanceof IUBundleContainer other)) { return false; } - IUBundleContainer other = (IUBundleContainer) obj; if (getIncludeAllRequired() != other.getIncludeAllRequired()) { return false; } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/LocalTargetHandle.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/LocalTargetHandle.java index 4f6a6cd4ac..0d828b7196 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/LocalTargetHandle.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/LocalTargetHandle.java @@ -154,8 +154,7 @@ private File getFile() { @Override public boolean equals(Object obj) { - if (obj instanceof LocalTargetHandle) { - LocalTargetHandle handle = (LocalTargetHandle) obj; + if (obj instanceof LocalTargetHandle handle) { return handle.fTimeStamp == fTimeStamp; } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/P2TargetUtils.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/P2TargetUtils.java index dfe2716530..88e6febe43 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/P2TargetUtils.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/P2TargetUtils.java @@ -583,8 +583,7 @@ private boolean checkProfile(ITargetDefinition target) throws CoreException { return installedIUs.isEmpty(); } for (ITargetLocation container : containers) { - if (container instanceof IUBundleContainer) { - IUBundleContainer bc = (IUBundleContainer) container; + if (container instanceof IUBundleContainer bc) { String[] ids = bc.getIds(); Version[] versions = bc.getVersions(); for (int j = 0; j < versions.length; j++) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ProfileBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ProfileBundleContainer.java index ee9cf08c20..26b307fcaa 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ProfileBundleContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/ProfileBundleContainer.java @@ -288,8 +288,7 @@ private File getConfigurationArea() throws CoreException { @Override public boolean equals(Object o) { - if (o instanceof ProfileBundleContainer) { - ProfileBundleContainer pbc = (ProfileBundleContainer) o; + if (o instanceof ProfileBundleContainer pbc) { return fHome.equals(pbc.fHome) && isNullOrEqual(pbc.fConfiguration, fConfiguration); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/RemoteTargetHandle.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/RemoteTargetHandle.java index 4a946bf17d..4fb842f877 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/RemoteTargetHandle.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/RemoteTargetHandle.java @@ -68,8 +68,7 @@ public boolean exists() { state = file.isFile() ? RemoteState.EXISTS : RemoteState.NOT_FOUND; } else { URLConnection connection = uri.toURL().openConnection(); - if (connection instanceof HttpURLConnection) { - HttpURLConnection http = (HttpURLConnection) connection; + if (connection instanceof HttpURLConnection http) { try { http.setInstanceFollowRedirects(true); http.setRequestMethod("HEAD"); //$NON-NLS-1$ diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java index bf8e1ea2cc..e0b5de9b91 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java @@ -1219,9 +1219,8 @@ private void serializeBundleContainers(ITargetLocation[] targetLocations, Elemen NodeList nodes = containersElement.getChildNodes(); for (int j = 0; j < nodes.getLength(); j++) { Node node = nodes.item(j); - if (node instanceof Element + if (node instanceof Element element && node.getNodeName().equalsIgnoreCase(TargetDefinitionPersistenceHelper.LOCATION)) { - Element element = (Element) node; String type = (element).getAttribute(TargetDefinitionPersistenceHelper.ATTR_LOCATION_TYPE); switch (type) { case IUBundleContainer.TYPE: diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/WorkspaceFileTargetHandle.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/WorkspaceFileTargetHandle.java index 71d41d38a5..57e1ba08a6 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/WorkspaceFileTargetHandle.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/WorkspaceFileTargetHandle.java @@ -106,8 +106,7 @@ public boolean exists() { @Override public boolean equals(Object obj) { - if (obj instanceof WorkspaceFileTargetHandle) { - WorkspaceFileTargetHandle handle = (WorkspaceFileTargetHandle) obj; + if (obj instanceof WorkspaceFileTargetHandle handle) { return fFile.equals(handle.fFile); } return false; diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/update/configurator/VersionedIdentifier.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/update/configurator/VersionedIdentifier.java index e04061ce19..f30abef445 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/update/configurator/VersionedIdentifier.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/update/configurator/VersionedIdentifier.java @@ -44,11 +44,10 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof VersionedIdentifier)) { + if (!(obj instanceof VersionedIdentifier other)) { return false; } - VersionedIdentifier other = (VersionedIdentifier) obj; if (!equalIdentifiers(other)) { return false; } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDESchemaHelper.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDESchemaHelper.java index d8e2e6b7e4..989f6b13cf 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDESchemaHelper.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDESchemaHelper.java @@ -63,8 +63,7 @@ public static Map getValidAttributes(ISchemaAttri if (restriction != null) { Object[] children = restriction.getChildren(); for (Object child : children) { - if (child instanceof ISchemaEnumeration) { - ISchemaEnumeration enumeration = (ISchemaEnumeration) child; + if (child instanceof ISchemaEnumeration enumeration) { String value = enumeration.getName(); if (value != null && value.length() > 0) { attributeMap.put(value, null); @@ -146,8 +145,7 @@ private static List keepGoing(IConfigurationElement eleme } private static String buildBasedOnValue(ISchemaObject object) { - if (object instanceof ISchemaElement && !(object instanceof ISchemaRootElement)) { - ISchemaElement schemaElement = (ISchemaElement) object; + if (object instanceof ISchemaElement schemaElement && !(object instanceof ISchemaRootElement)) { ISchema schema = schemaElement.getSchema(); ISchemaElement[] elements = schema.getElements(); for (ISchemaElement element : elements) { diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PackageFragmentRootPropertyTester.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PackageFragmentRootPropertyTester.java index dbb23c8600..bb0243ff7a 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PackageFragmentRootPropertyTester.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PackageFragmentRootPropertyTester.java @@ -42,8 +42,7 @@ public class PackageFragmentRootPropertyTester extends PropertyTester { public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (property.equals(PROP_IN_PLUGIN_CONTAINER)) { - if (receiver instanceof IPackageFragmentRoot) { - IPackageFragmentRoot element = (IPackageFragmentRoot) receiver; + if (receiver instanceof IPackageFragmentRoot element) { try { IClasspathEntry entry = element.getRawClasspathEntry(); IPath path = entry.getPath(); diff --git a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/DocumentObject.java b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/DocumentObject.java index bfee2d0acb..a505faa9fb 100644 --- a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/DocumentObject.java +++ b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/DocumentObject.java @@ -136,8 +136,7 @@ protected void firePropertyChanged(String property, Object oldValue, Object newV * @param newValue */ private void firePropertyChanged(Object object, String property, Object oldValue, Object newValue) { - if (fModel.isEditable() && (fModel instanceof IModelChangeProvider)) { - IModelChangeProvider provider = (IModelChangeProvider) fModel; + if (fModel.isEditable() && (fModel instanceof IModelChangeProvider provider)) { provider.fireModelObjectChanged(object, property, oldValue, newValue); } } @@ -155,8 +154,7 @@ protected void fireStructureChanged(Object child, int changeType) { * @param changeType */ protected void fireStructureChanged(Object[] children, int changeType) { - if (fModel.isEditable() && (fModel instanceof IModelChangeProvider)) { - IModelChangeProvider provider = (IModelChangeProvider) fModel; + if (fModel.isEditable() && (fModel instanceof IModelChangeProvider provider)) { IModelChangedEvent event = new ModelChangedEvent(provider, changeType, children, null); provider.fireModelChanged(event); } diff --git a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/BundleTextChangeListener.java b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/BundleTextChangeListener.java index 166245273e..69f79eb5fa 100644 --- a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/BundleTextChangeListener.java +++ b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/BundleTextChangeListener.java @@ -92,8 +92,7 @@ public void modelChanged(IModelChangedEvent event) { object = ((PackageFriend) object).getHeader(); } - if (object instanceof ManifestHeader) { - ManifestHeader header = (ManifestHeader) object; + if (object instanceof ManifestHeader header) { Object op = fOperationTable.remove(header); if (fReadableNames != null) { fReadableNames.remove(op); diff --git a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginBaseNode.java b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginBaseNode.java index 6f6dad853a..84b68baa43 100644 --- a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginBaseNode.java +++ b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginBaseNode.java @@ -35,8 +35,7 @@ public abstract class PluginBaseNode extends PluginObjectNode implements IPlugin @Override public void add(IPluginLibrary library) throws CoreException { IDocumentElementNode parent = getEnclosingElement("runtime", true); //$NON-NLS-1$ - if (library instanceof PluginLibraryNode) { - PluginLibraryNode node = (PluginLibraryNode) library; + if (library instanceof PluginLibraryNode node) { node.setModel(getModel()); parent.addChildNode(node); fireStructureChanged(library, IModelChangedEvent.INSERT); @@ -46,8 +45,7 @@ public void add(IPluginLibrary library) throws CoreException { @Override public void add(IPluginImport pluginImport) throws CoreException { IDocumentElementNode parent = getEnclosingElement("requires", true); //$NON-NLS-1$ - if (pluginImport instanceof PluginImportNode) { - PluginImportNode node = (PluginImportNode) pluginImport; + if (pluginImport instanceof PluginImportNode node) { parent.addChildNode(node); fireStructureChanged(pluginImport, IModelChangedEvent.INSERT); } @@ -56,8 +54,7 @@ public void add(IPluginImport pluginImport) throws CoreException { public void add(IPluginImport[] pluginImports) { IDocumentElementNode parent = getEnclosingElement("requires", true); //$NON-NLS-1$ for (IPluginImport pluginImport : pluginImports) { - if (pluginImport != null && pluginImport instanceof PluginImportNode) { - PluginImportNode node = (PluginImportNode) pluginImport; + if (pluginImport != null && pluginImport instanceof PluginImportNode node) { parent.addChildNode(node); } } @@ -198,8 +195,7 @@ public void setSchemaVersion(String schemaVersion) throws CoreException { @Override public void add(IPluginExtension extension) throws CoreException { - if (extension instanceof PluginExtensionNode) { - PluginExtensionNode node = (PluginExtensionNode) extension; + if (extension instanceof PluginExtensionNode node) { node.setModel(getModel()); addChildNode(node); fireStructureChanged(extension, IModelChangedEvent.INSERT); @@ -226,8 +222,7 @@ public void add(IPluginExtension extension, int position) throws CoreException { @Override public void add(IPluginExtensionPoint extensionPoint) throws CoreException { - if (extensionPoint instanceof PluginExtensionPointNode) { - PluginExtensionPointNode node = (PluginExtensionPointNode) extensionPoint; + if (extensionPoint instanceof PluginExtensionPointNode node) { node.setModel(getModel()); extensionPoint.setInTheModel(true); node.setParentNode(this); diff --git a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginObjectNode.java b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginObjectNode.java index d11d9ce818..41b8cfcab3 100644 --- a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginObjectNode.java +++ b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginObjectNode.java @@ -170,8 +170,7 @@ protected void fireStructureChanged(IPluginObject[] children, int changeType) { private void fireModelChanged(IModelChangedEvent e) { IModel model = getModel(); - if (model.isEditable() && model instanceof IModelChangeProvider) { - IModelChangeProvider provider = (IModelChangeProvider) model; + if (model.isEditable() && model instanceof IModelChangeProvider provider) { provider.fireModelChanged(e); } } diff --git a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/XMLTextChangeListener.java b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/XMLTextChangeListener.java index 3e283991b9..b6855e07a6 100644 --- a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/XMLTextChangeListener.java +++ b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/XMLTextChangeListener.java @@ -468,10 +468,9 @@ public void modelChanged(IModelChangedEvent event) { return; } for (int i = 0; i < objects.length; i++) { - if (!(objects[i] instanceof IDocumentElementNode)) { + if (!(objects[i] instanceof IDocumentElementNode node)) { continue; } - IDocumentElementNode node = (IDocumentElementNode) objects[i]; Object op = fOperationTable.remove(node); fOperationList.remove(op); if (fReadableNames != null) {