@Test public void sort_by_signature_when_constructors_have_same_number_of_parameters() throws NoSuchMethodException { this.query = new DefaultConstructorQuery(new ConstructorParameterCountComparator()); Class<?> targetClass = TypeWithMultipleConstructorsHavingSameParameterCount.class; List<Constructor<?>> constructors = this.query.getConstructorsForClass(targetClass); assertEquals(4, constructors.size()); assertEquals(targetClass.getConstructor(String.class, String.class), constructors.get(0)); assertEquals(targetClass.getConstructor(String.class, List.class), constructors.get(1)); assertEquals(targetClass.getConstructor(List.class, String.class), constructors.get(2)); assertEquals(targetClass.getConstructor(List.class, List.class), constructors.get(3)); }
@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);  }