[Clirr-devel] CVS: clirr/core/src/java/net/sf/clirr/core/internal/checks InterfaceSetCheck.java,1.3,
Status: Alpha
Brought to you by:
lkuehne
From: <lk...@us...> - 2004-08-21 11:10:49
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24975 Modified Files: InterfaceSetCheck.java Log Message: avoid ClassCastException that was caused by adding Strings to a Set and trying to extract JavaClass objects later This should fix the Maven plugin problem that Vincent experienced Index: InterfaceSetCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/InterfaceSetCheck.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InterfaceSetCheck.java 16 Jul 2004 10:16:50 -0000 1.3 +++ InterfaceSetCheck.java 21 Aug 2004 11:10:37 -0000 1.4 @@ -19,8 +19,8 @@ package net.sf.clirr.core.internal.checks; -import java.util.HashSet; import java.util.Set; +import java.util.TreeSet; import net.sf.clirr.core.Severity; import net.sf.clirr.core.Message; @@ -110,13 +110,20 @@ return true; } + /** + * Creates a Set of JavaClass objects. + * @param classes the classes to include in the set, might contain duplicates + * @return Set<JavaClass> + */ private Set createClassSet(JavaClass[] classes) { - Set current = new HashSet(); + // JavaClass does not define equals(), so we use a Set implementation + // that determines equality by invoking a Comparator instead of calling equals() + + Set current = new TreeSet(JavaClassNameComparator.COMPARATOR); for (int i = 0; i < classes.length; i++) { - String currentInterface = classes[i].getClassName(); - current.add(currentInterface); + current.add(classes[i]); } return current; } |