use of com.blackducksoftware.integration.hub.detect.workflow.search.result.YieldedDetectorResult in project hub-detect by blackducksoftware.
the class DetectorSearchEvaluator method searchable.
public DetectorResult searchable(final DetectorSearchRule searchRules, final List<Detector> appliedSoFar, DetectorEnvironment environment) {
Detector detector = searchRules.getDetector();
final DetectorType detectorType = detector.getDetectorType();
if (!environment.getDetectorFilter().shouldInclude(detectorType.toString())) {
return new ExcludedDetectorResult();
}
final int maxDepth = searchRules.getMaxDepth();
if (environment.getDepth() > maxDepth) {
return new MaxDepthExceededDetectorResult(environment.getDepth(), maxDepth);
}
final Set<Detector> yieldTo = appliedSoFar.stream().filter(it -> searchRules.getYieldsTo().contains(it)).collect(Collectors.toSet());
if (yieldTo.size() > 0) {
return new YieldedDetectorResult(yieldTo);
}
final boolean nestable = searchRules.isNestable();
if (environment.getForceNestedSearch()) {
return new ForcedNestedPassedDetectorResult();
} else if (nestable) {
if (environment.getAppliedToParent().stream().anyMatch(applied -> applied.isSame(detector))) {
return new NotSelfNestableDetectorResult();
}
} else if (!nestable && environment.getAppliedToParent().size() > 0) {
return new NotNestableDetectorResult();
}
return new PassedDetectorResult();
}
Aggregations