Search in sources :

Example 1 with DetectableInfo

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;
}
Also used : Arrays(java.util.Arrays) List(java.util.List) DetectDetectableFactory(com.synopsys.integration.detect.tool.detector.factory.DetectDetectableFactory) DetectableInfo(com.synopsys.integration.detectable.detectable.annotation.DetectableInfo) DetectorRule(com.synopsys.integration.detector.rule.DetectorRule) Gson(com.google.gson.Gson) Detectable(com.synopsys.integration.detectable.Detectable) DetectorRuleFactory(com.synopsys.integration.detect.tool.detector.DetectorRuleFactory) Optional(java.util.Optional) DetectorRuleSet(com.synopsys.integration.detector.rule.DetectorRuleSet) Collectors(java.util.stream.Collectors) DetectProperties(com.synopsys.integration.detect.configuration.DetectProperties) DetectorRule(com.synopsys.integration.detector.rule.DetectorRule) Detectable(com.synopsys.integration.detectable.Detectable) DetectableInfo(com.synopsys.integration.detectable.detectable.annotation.DetectableInfo)

Aggregations

Gson (com.google.gson.Gson)1 DetectProperties (com.synopsys.integration.detect.configuration.DetectProperties)1 DetectorRuleFactory (com.synopsys.integration.detect.tool.detector.DetectorRuleFactory)1 DetectDetectableFactory (com.synopsys.integration.detect.tool.detector.factory.DetectDetectableFactory)1 Detectable (com.synopsys.integration.detectable.Detectable)1 DetectableInfo (com.synopsys.integration.detectable.detectable.annotation.DetectableInfo)1 DetectorRule (com.synopsys.integration.detector.rule.DetectorRule)1 DetectorRuleSet (com.synopsys.integration.detector.rule.DetectorRuleSet)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1