Source:
<code>public VersionTypeValidation validateWorkflowSet(Set<SourceFile> sourcefiles, String primaryDescriptorFilePath) { List<DescriptorLanguage.FileType> fileTypes = new ArrayList<>(Collections.singletonList(DescriptorLanguage.FileType.DOCKSTORE_CWL)); Set<SourceFile> filteredSourcefiles = filterSourcefiles(sourcefiles, fileTypes); Optional<SourceFile> mainDescriptor = filteredSourcefiles.stream().filter((sourceFile -> Objects.equals(sourceFile.getPath(), primaryDescriptorFilePath))).findFirst(); boolean isValid = true; StringBuilder validationMessage = new StringBuilder(); Map<String, String> validationMessageObject = new HashMap<>(); if (mainDescriptor.isPresent()) { Yaml yaml = new Yaml(); String content = mainDescriptor.get().getContent(); if (content == null || content.isEmpty()) { isValid = false; validationMessage.append("Primary descriptor is empty."); } else if (!content.contains("class: Workflow")) { isValid = false; validationMessage.append("A CWL workflow requires 'class: Workflow'."); if (content.contains("class: CommandLineTool") || content.contains("class: ExpressionTool")) { String cwlClass = content.contains("class: CommandLineTool") ? "CommandLineTool" : "ExpressionTool"; validationMessage.append(" This file contains 'class: ").append(cwlClass).append("'. Did you mean to register a tool?"); } } else if (!this.isValidCwl(content, yaml)) { isValid = false; validationMessage.append("Invalid CWL version."); } } else { validationMessage.append("Primary CWL descriptor is not present."); isValid = false; } if (isValid) { <START> return new VersionTypeValidation(true, new HashMap<>()); <END> } else { validationMessageObject.put(primaryDescriptorFilePath, validationMessage.toString()); return new VersionTypeValidation(false, validationMessageObject); } }</code><technical_language>do Collections.emptyMap() instead of creating a new object, planning add stuff map later. tiniest of micro-optimizations. :)</technical_language>

Target:
public VersionTypeValidation validateWorkflowSet(Set<SourceFile> sourcefiles, String primaryDescriptorFilePath) { List<DescriptorLanguage.FileType> fileTypes = new ArrayList<>(Collections.singletonList(DescriptorLanguage.FileType.DOCKSTORE_CWL)); Set<SourceFile> filteredSourcefiles = filterSourcefiles(sourcefiles, fileTypes); Optional<SourceFile> mainDescriptor = filteredSourcefiles.stream().filter((sourceFile -> Objects.equals(sourceFile.getPath(), primaryDescriptorFilePath))).findFirst(); boolean isValid = true; StringBuilder validationMessage = new StringBuilder(); Map<String, String> validationMessageObject = new HashMap<>(); if (mainDescriptor.isPresent()) { Yaml yaml = new Yaml(); String content = mainDescriptor.get().getContent(); if (content == null || content.isEmpty()) { isValid = false; validationMessage.append("Primary descriptor is empty."); } else if (!content.contains("class: Workflow")) { isValid = false; validationMessage.append("A CWL workflow requires 'class: Workflow'."); if (content.contains("class: CommandLineTool") || content.contains("class: ExpressionTool")) { String cwlClass = content.contains("class: CommandLineTool") ? "CommandLineTool" : "ExpressionTool"; validationMessage.append(" This file contains 'class: ").append(cwlClass).append("'. Did you mean to register a tool?"); } } else if (!this.isValidCwl(content, yaml)) { isValid = false; validationMessage.append("Invalid CWL version."); } } else { validationMessage.append("Primary CWL descriptor is not present."); isValid = false; } if (isValid) { return new VersionTypeValidation(true, Collections.emptyMap()); } else { validationMessageObject.put(primaryDescriptorFilePath, validationMessage.toString()); return new VersionTypeValidation(false, validationMessageObject); } }