use of com.synopsys.integration.detect.workflow.nameversion.decision.UniqueDetectorDecision in project synopsys-detect by blackducksoftware.
the class DetectorNameVersionDecider method decideProjectNameVersionFromDetector.
private NameVersionDecision decideProjectNameVersionFromDetector(List<DetectorProjectInfo> projectNamePossibilities, DetectorType preferredDetectorType) {
if (preferredDetectorType != null) {
List<DetectorProjectInfo> preferredPossibilities = projectNamePossibilities.stream().filter(info -> info.getDetectorType() == preferredDetectorType).collect(Collectors.toList());
List<DetectorProjectInfo> lowestDepthPossibilities = projectNamesAtLowestDepth(preferredPossibilities);
List<DetectorProjectInfo> uniqueDetectorsAtLowestDepth = filterUniqueDetectorsOnly(lowestDepthPossibilities);
if (uniqueDetectorsAtLowestDepth.isEmpty()) {
return new PreferredDetectorNotFoundDecision(preferredDetectorType);
} else if (uniqueDetectorsAtLowestDepth.size() == 1) {
return new PreferredDetectorDecision(uniqueDetectorsAtLowestDepth.get(0));
} else {
return new TooManyPreferredDetectorTypesFoundDecision(preferredDetectorType);
}
} else {
List<DetectorProjectInfo> lowestDepthPossibilities = projectNamesAtLowestDepth(projectNamePossibilities);
List<DetectorProjectInfo> uniqueDetectorsAtLowestDepth = filterUniqueDetectorsOnly(lowestDepthPossibilities);
if (uniqueDetectorsAtLowestDepth.size() == 1) {
return new UniqueDetectorDecision(uniqueDetectorsAtLowestDepth.get(0));
} else if (uniqueDetectorsAtLowestDepth.size() > 1) {
return decideProjectNameVersionArbitrarily(lowestDepthPossibilities);
} else {
return new UniqueDetectorNotFoundDecision();
}
}
}
Aggregations