@Test public void sorts_constructors_using_given_comparator_ascending_parameter_count() { this.query = new DefaultConstructorQuery(new ConstructorParameterCountComparator()); List<Constructor<?>> constructors = this.query.getConstructorsForClass(TwoConstructorType.class); assertEquals(2, constructors.size()); assertEquals(expectedConstructorOneParameter, constructors.get(0)); assertEquals(expectedConstructorTwoParameters, constructors.get(1)); }
@Override public List<Constructor<?>> getConstructorsForClass(Class<?> clazz) { List<Constructor<?>> constructors = Arrays.asList(clazz.getConstructors()); if (this.comparator != null) { Collections.sort(constructors, this.comparator); } return constructors; }
DefaultConstructorQuery implements ConstructorQuery { @Override public List<Constructor<?>> getConstructorsForClass(Class<?> clazz) { List<Constructor<?>> constructors = Arrays.asList(clazz.getConstructors()); if (this.comparator != null) { Collections.sort(constructors, this.comparator); } return constructors; } }
DefaultConstructorQuery implements ConstructorQuery { @Override public List<Constructor<?>> getConstructorsForClass(Class<?> clazz) { List<Constructor<?>> constructors = Arrays.asList(clazz.getConstructors()); if (this.comparator != null) { Collections.sort(constructors, this.comparator); } return constructors; } DefaultConstructorQuery();  DefaultConstructorQuery(Comparator<Constructor<?>> comparator); }
DefaultConstructorQuery implements ConstructorQuery { @Override public List<Constructor<?>> getConstructorsForClass(Class<?> clazz) { List<Constructor<?>> constructors = Arrays.asList(clazz.getConstructors()); if (this.comparator != null) { Collections.sort(constructors, this.comparator); } return constructors; } DefaultConstructorQuery();  DefaultConstructorQuery(Comparator<Constructor<?>> comparator); @Override List<Constructor<?>> getConstructorsForClass(Class<?> clazz); }
DefaultConstructorQuery implements ConstructorQuery { @Override public List<Constructor<?>> getConstructorsForClass(Class<?> clazz) { List<Constructor<?>> constructors = Arrays.asList(clazz.getConstructors()); if (this.comparator != null) { Collections.sort(constructors, this.comparator); } return constructors; } DefaultConstructorQuery();  DefaultConstructorQuery(Comparator<Constructor<?>> comparator); @Override List<Constructor<?>> getConstructorsForClass(Class<?> clazz);  }