@Test public void test() throws Exception { SpecScanner sc = new SpecScanner(); List<Constraint> l = sc.scan(); Assert.assertEquals(l.size(), 27); long from = System.currentTimeMillis(); System.out.println(l.stream().map(Constraint::pretty).collect(Collectors.joining("\n"))); System.out.println(System.currentTimeMillis() - from + " ms"); }
public List<Constraint> scan() throws IllegalAccessException, InstantiationException, IOException { List<CoreConstraint> coreAnnots = Collections.synchronizedList(new ArrayList<>()); List<Class<? extends Function>> funcs = Collections.synchronizedList(new ArrayList<>()); scanner.matchClassesImplementing(Function.class, funcs::add); scanner.matchClassesWithAnnotation(CoreConstraint.class, c -> coreAnnots.add(c.getAnnotation(CoreConstraint.class))); scanner.matchClassesWithAnnotation(CoreConstraints.class, c -> { CoreConstraint[] x = c.getAnnotationsByType(CoreConstraint.class); coreAnnots.addAll(Arrays.asList(x)); }); scanner.matchClassesWithAnnotation(SideConstraint.class, c -> sides.add(new Side(c.getAnnotation(SideConstraint.class), (Class<? extends SatConstraint>) c))); scanner.scan(Runtime.getRuntime().availableProcessors() - 1); for (Class<? extends Function> f : funcs) { if (!f.equals(Constraint.class)) { functions.add(f.newInstance()); } } scanner.matchClassesImplementing(Function.class, c -> { try { functions.add(c.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException(e); } }); List<Constraint> cstrs = new ArrayList<>(); for (CoreConstraint c : coreAnnots) { cstrs.add(parseCore2(c)); } List<Constraint> l = new ArrayList<>(); for (Side s : resolveDependencies(sides)) { Constraint c = parseSide(s, l); l.add(c); } cstrs.addAll(l); return cstrs; }
SpecScanner { public List<Constraint> scan() throws IllegalAccessException, InstantiationException, IOException { List<CoreConstraint> coreAnnots = Collections.synchronizedList(new ArrayList<>()); List<Class<? extends Function>> funcs = Collections.synchronizedList(new ArrayList<>()); scanner.matchClassesImplementing(Function.class, funcs::add); scanner.matchClassesWithAnnotation(CoreConstraint.class, c -> coreAnnots.add(c.getAnnotation(CoreConstraint.class))); scanner.matchClassesWithAnnotation(CoreConstraints.class, c -> { CoreConstraint[] x = c.getAnnotationsByType(CoreConstraint.class); coreAnnots.addAll(Arrays.asList(x)); }); scanner.matchClassesWithAnnotation(SideConstraint.class, c -> sides.add(new Side(c.getAnnotation(SideConstraint.class), (Class<? extends SatConstraint>) c))); scanner.scan(Runtime.getRuntime().availableProcessors() - 1); for (Class<? extends Function> f : funcs) { if (!f.equals(Constraint.class)) { functions.add(f.newInstance()); } } scanner.matchClassesImplementing(Function.class, c -> { try { functions.add(c.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException(e); } }); List<Constraint> cstrs = new ArrayList<>(); for (CoreConstraint c : coreAnnots) { cstrs.add(parseCore2(c)); } List<Constraint> l = new ArrayList<>(); for (Side s : resolveDependencies(sides)) { Constraint c = parseSide(s, l); l.add(c); } cstrs.addAll(l); return cstrs; } }
SpecScanner { public List<Constraint> scan() throws IllegalAccessException, InstantiationException, IOException { List<CoreConstraint> coreAnnots = Collections.synchronizedList(new ArrayList<>()); List<Class<? extends Function>> funcs = Collections.synchronizedList(new ArrayList<>()); scanner.matchClassesImplementing(Function.class, funcs::add); scanner.matchClassesWithAnnotation(CoreConstraint.class, c -> coreAnnots.add(c.getAnnotation(CoreConstraint.class))); scanner.matchClassesWithAnnotation(CoreConstraints.class, c -> { CoreConstraint[] x = c.getAnnotationsByType(CoreConstraint.class); coreAnnots.addAll(Arrays.asList(x)); }); scanner.matchClassesWithAnnotation(SideConstraint.class, c -> sides.add(new Side(c.getAnnotation(SideConstraint.class), (Class<? extends SatConstraint>) c))); scanner.scan(Runtime.getRuntime().availableProcessors() - 1); for (Class<? extends Function> f : funcs) { if (!f.equals(Constraint.class)) { functions.add(f.newInstance()); } } scanner.matchClassesImplementing(Function.class, c -> { try { functions.add(c.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException(e); } }); List<Constraint> cstrs = new ArrayList<>(); for (CoreConstraint c : coreAnnots) { cstrs.add(parseCore2(c)); } List<Constraint> l = new ArrayList<>(); for (Side s : resolveDependencies(sides)) { Constraint c = parseSide(s, l); l.add(c); } cstrs.addAll(l); return cstrs; } SpecScanner(); }
SpecScanner { public List<Constraint> scan() throws IllegalAccessException, InstantiationException, IOException { List<CoreConstraint> coreAnnots = Collections.synchronizedList(new ArrayList<>()); List<Class<? extends Function>> funcs = Collections.synchronizedList(new ArrayList<>()); scanner.matchClassesImplementing(Function.class, funcs::add); scanner.matchClassesWithAnnotation(CoreConstraint.class, c -> coreAnnots.add(c.getAnnotation(CoreConstraint.class))); scanner.matchClassesWithAnnotation(CoreConstraints.class, c -> { CoreConstraint[] x = c.getAnnotationsByType(CoreConstraint.class); coreAnnots.addAll(Arrays.asList(x)); }); scanner.matchClassesWithAnnotation(SideConstraint.class, c -> sides.add(new Side(c.getAnnotation(SideConstraint.class), (Class<? extends SatConstraint>) c))); scanner.scan(Runtime.getRuntime().availableProcessors() - 1); for (Class<? extends Function> f : funcs) { if (!f.equals(Constraint.class)) { functions.add(f.newInstance()); } } scanner.matchClassesImplementing(Function.class, c -> { try { functions.add(c.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException(e); } }); List<Constraint> cstrs = new ArrayList<>(); for (CoreConstraint c : coreAnnots) { cstrs.add(parseCore2(c)); } List<Constraint> l = new ArrayList<>(); for (Side s : resolveDependencies(sides)) { Constraint c = parseSide(s, l); l.add(c); } cstrs.addAll(l); return cstrs; } SpecScanner(); List<Constraint> scan(); }
SpecScanner { public List<Constraint> scan() throws IllegalAccessException, InstantiationException, IOException { List<CoreConstraint> coreAnnots = Collections.synchronizedList(new ArrayList<>()); List<Class<? extends Function>> funcs = Collections.synchronizedList(new ArrayList<>()); scanner.matchClassesImplementing(Function.class, funcs::add); scanner.matchClassesWithAnnotation(CoreConstraint.class, c -> coreAnnots.add(c.getAnnotation(CoreConstraint.class))); scanner.matchClassesWithAnnotation(CoreConstraints.class, c -> { CoreConstraint[] x = c.getAnnotationsByType(CoreConstraint.class); coreAnnots.addAll(Arrays.asList(x)); }); scanner.matchClassesWithAnnotation(SideConstraint.class, c -> sides.add(new Side(c.getAnnotation(SideConstraint.class), (Class<? extends SatConstraint>) c))); scanner.scan(Runtime.getRuntime().availableProcessors() - 1); for (Class<? extends Function> f : funcs) { if (!f.equals(Constraint.class)) { functions.add(f.newInstance()); } } scanner.matchClassesImplementing(Function.class, c -> { try { functions.add(c.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException(e); } }); List<Constraint> cstrs = new ArrayList<>(); for (CoreConstraint c : coreAnnots) { cstrs.add(parseCore2(c)); } List<Constraint> l = new ArrayList<>(); for (Side s : resolveDependencies(sides)) { Constraint c = parseSide(s, l); l.add(c); } cstrs.addAll(l); return cstrs; } SpecScanner(); List<Constraint> scan();  }