use of com.synopsys.integration.detectable.detectable.annotation.DetectableInfo in project synopsys-detect by blackducksoftware.
the class HelpJsonManager method convertDetectorRule.
private HelpJsonDetector convertDetectorRule(DetectorRule rule, DetectorRuleSet ruleSet) {
HelpJsonDetector helpData = new HelpJsonDetector();
helpData.setDetectorName(rule.getName());
helpData.setDetectorDescriptiveName(rule.getDescriptiveName());
helpData.setDetectorType(rule.getDetectorType().toString());
helpData.setMaxDepth(rule.getMaxDepth());
helpData.setNestable(rule.isNestable());
helpData.setNestInvisible(rule.isNestInvisible());
helpData.setYieldsTo(ruleSet.getYieldsTo(rule).stream().map(DetectorRule::getDescriptiveName).collect(Collectors.toList()));
// Attempt to create the detectable.
// Not currently possible. Need a full DetectableConfiguration to be able to make Detectables.
Class<Detectable> detectableClass = rule.getDetectableClass();
Optional<DetectableInfo> infoSearch = Arrays.stream(detectableClass.getAnnotations()).filter(annotation -> annotation instanceof DetectableInfo).map(annotation -> (DetectableInfo) annotation).findFirst();
if (infoSearch.isPresent()) {
DetectableInfo info = infoSearch.get();
helpData.setDetectableLanguage(info.language());
helpData.setDetectableRequirementsMarkdown(info.requirementsMarkdown());
helpData.setDetectableForge(info.forge());
}
return helpData;
}
Aggregations