Source:
<code>protected void handleVerifyUnverify(String entry, String versionName, String verifySource, boolean unverifyRequest, boolean isScript) { String action = "verify"; if (unverifyRequest) { action = "unverify"; } boolean toOverwrite = true; try { Workflow workflow = workflowsApi.getWorkflowByPath(entry); <START> List<WorkflowVersion> versions = workflow.getWorkflowVersions(); <END> WorkflowVersion versionToUpdate = null; for (WorkflowVersion workflowVersion : versions) { if (workflowVersion.getName().equals(versionName)) { versionToUpdate = workflowVersion; break; } } if (versionToUpdate == null) { errorMessage(versionName + " is not a valid version for " + entry, Client.CLIENT_ERROR); } VerifyRequest verifyRequest = new VerifyRequest(); if (unverifyRequest) { verifyRequest.setVerify(false); verifyRequest.setVerifiedSource(null); } else { if (versionToUpdate.getVerified() && !isScript) { Scanner scanner = new Scanner(System.in, "utf-8"); out("The version " + versionName + " has already been verified by \'" + versionToUpdate.getVerifiedSource() + "\'"); out("Would you like to overwrite this with \'" + verifySource + "\'? (y/n)"); String overwrite = scanner.nextLine(); if (overwrite.toLowerCase().equals("y")) { verifyRequest.setVerify(true); verifyRequest.setVerifiedSource(verifySource); } else { toOverwrite = false; } } else { verifyRequest.setVerify(true); verifyRequest.setVerifiedSource(verifySource); } } if (toOverwrite) { List<WorkflowVersion> result = workflowsApi.verifyWorkflowVersion(workflow.getId(), versionToUpdate.getId(), verifyRequest); if (unverifyRequest) { out("Version " + versionName + " has been unverified."); } else { out("Version " + versionName + " has been verified by \'" + verifySource + "\'"); } } } catch (ApiException ex) { exceptionMessage(ex, "Unable to " + action + " version " + versionName, Client.API_ERROR); } }</code><technical_language>I this more readable (and simple) a lambda</technical_language>

Target:
protected void handleVerifyUnverify(String entry, String versionName, String verifySource, boolean unverifyRequest, boolean isScript) { boolean toOverwrite = true; try { Workflow workflow = workflowsApi.getWorkflowByPath(entry); List<WorkflowVersion> versions = workflow.getWorkflowVersions(); WorkflowVersion versionToUpdate = versions .stream() .filter((WorkflowVersion u) -> u.getName().equals(versionName)) .findFirst() .get(); if (versionToUpdate == null) { errorMessage(versionName + " is not a valid version for " + entry, Client.CLIENT_ERROR); } VerifyRequest verifyRequest = new VerifyRequest(); if (unverifyRequest) { verifyRequest.setVerify(false); verifyRequest.setVerifiedSource(null); } else { if (versionToUpdate.getVerified() && !isScript) { Scanner scanner = new Scanner(System.in, "utf-8"); out("The version " + versionName + " has already been verified by \'" + versionToUpdate.getVerifiedSource() + "\'"); out("Would you like to overwrite this with \'" + verifySource + "\'? (y/n)"); String overwrite = scanner.nextLine(); if (overwrite.toLowerCase().equals("y")) { verifyRequest.setVerify(true); verifyRequest.setVerifiedSource(verifySource); } else { toOverwrite = false; } } else { verifyRequest.setVerify(true); verifyRequest.setVerifiedSource(verifySource); } } if (toOverwrite) { List<WorkflowVersion> result = workflowsApi.verifyWorkflowVersion(workflow.getId(), versionToUpdate.getId(), verifyRequest); if (unverifyRequest) { out("Version " + versionName + " has been unverified."); } else { out("Version " + versionName + " has been verified by \'" + verifySource + "\'"); } } } catch (ApiException ex) { exceptionMessage(ex, "Unable to " + (unverifyRequest ? "unverify" : "verify") + " version " + versionName, Client.API_ERROR); } }