Skip to content

Commit d72bd75

Browse files
committed
Modernize Java idioms in WizardNewFolderMainPage
1 parent ce4e10f commit d72bd75

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFolderMainPage.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,15 @@ public IResource getResource() {
200200
if (path != null) {
201201
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
202202
IResource resource = root.findMember(path);
203-
if (resource != null && resource instanceof IContainer) {
203+
if (resource instanceof IContainer container) {
204204
String resourceName = resourceGroup.getResource();
205-
if (resourceName.length() > 0) {
205+
if (!resourceName.isEmpty()) {
206206
try {
207-
return ((IContainer) resource).getFolder(IPath.fromOSString(resourceName));
207+
return container.getFolder(IPath.fromOSString(resourceName));
208208
} catch (IllegalArgumentException e) {
209209
// continue below.
210210
}
211211
}
212-
return resource;
213212
}
214213
return resource;
215214
}
@@ -232,13 +231,11 @@ private void setupLinkedResourceTarget() {
232231
try {
233232
if (isFilteredByParent()) {
234233
URI existingLink = linkedResourceGroup.getLinkTargetURI();
235-
boolean setDefaultLinkValue = false;
236-
if (existingLink == null) {
237-
setDefaultLinkValue = true;
238-
} else {
234+
boolean setDefaultLinkValue = existingLink == null;
235+
if (!setDefaultLinkValue) {
239236
IPath path = URIUtil.toPath(existingLink);
240237
if (path != null) {
241-
setDefaultLinkValue = path.toPortableString().length() > 0;
238+
setDefaultLinkValue = !path.toPortableString().isEmpty();
242239
}
243240
}
244241

@@ -450,10 +447,10 @@ public IFolder createNewFolder() {
450447
op1.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
451448
} catch (final ExecutionException e) {
452449
getContainer().getShell().getDisplay().syncExec(() -> {
453-
if (e.getCause() instanceof CoreException) {
450+
if (e.getCause() instanceof CoreException coreException) {
454451
ErrorDialog.openError(getContainer().getShell(), // Was Utilities.getFocusShell()
455452
IDEWorkbenchMessages.WizardNewFolderCreationPage_errorTitle, null, // no special message
456-
((CoreException) e.getCause()).getStatus());
453+
coreException.getStatus());
457454
} else {
458455
IDEWorkbenchPlugin.log(getClass(), "createNewFolder()", e.getCause()); //$NON-NLS-1$
459456
MessageDialog.openError(getContainer().getShell(),
@@ -771,7 +768,7 @@ private boolean isFilteredByParent() {
771768
if (createVirtualFolder) {
772769
return false;
773770
}
774-
if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) {
771+
if (linkedResourceGroup == null || linkedResourceGroup.isEnabled()) {
775772
return false;
776773
}
777774
IPath containerPath = resourceGroup.getContainerFullPath();
@@ -782,7 +779,7 @@ private boolean isFilteredByParent() {
782779
if (resourceName == null) {
783780
return false;
784781
}
785-
if (resourceName.length() > 0) {
782+
if (!resourceName.isEmpty()) {
786783
IPath newFolderPath = containerPath.append(resourceName);
787784
if (newFolderPath.segmentCount() < 2) {
788785
return false;

0 commit comments

Comments
 (0)