public Detector2 createDetector2(BugReporter bugReporter) { if (Detector2.class.isAssignableFrom(detectorClass)) { try { Constructor<?> constructor = detectorClass.getConstructor(constructorArgTypes); return (Detector2) constructor.newInstance(new Object[] { bugReporter }); } catch (Exception e) { throw new RuntimeException("Could not instantiate " + detectorClass.getName() + " as Detector2", e); } } if (Detector.class.isAssignableFrom(detectorClass)) { if (NonReportingDetector.class.isAssignableFrom(detectorClass)) { return new NonReportingDetectorToDetector2Adapter(createDetector(bugReporter)); } return new DetectorToDetector2Adapter(createDetector(bugReporter)); } throw new RuntimeException("Class " + detectorClass.getName() + " is not a detector class"); }
private static Detector2 adapt(Detector detector) { return new DetectorToDetector2Adapter(detector); }
public void runDetectorOnClass(Detector pluginDetector, Class<?> classToTest, BugReporter bugReporter) throws Exception { assertInitialised(); Singleton.doRunDetectorOnClass(new DetectorToDetector2Adapter(pluginDetector), classToTest, bugReporter); } }
public Detector2 createDetector2(BugReporter bugReporter) { if (Detector2.class.isAssignableFrom(detectorClass)) { try { Constructor<?> constructor = detectorClass.getConstructor(constructorArgTypes); return (Detector2) constructor.newInstance(new Object[] { bugReporter }); } catch (Exception e) { throw new RuntimeException("Could not instantiate " + detectorClass.getName() + " as Detector2", e); } } if (Detector.class.isAssignableFrom(detectorClass)) { if (NonReportingDetector.class.isAssignableFrom(detectorClass)) { return new NonReportingDetectorToDetector2Adapter(createDetector(bugReporter)); } return new DetectorToDetector2Adapter(createDetector(bugReporter)); } throw new RuntimeException("Class " + detectorClass.getName() + " is not a detector class"); }