- Revision
- 1157
- Author
- rfscholte
- Date
- 2011-04-07 15:37:32 -0500 (Thu, 07 Apr 2011)
Log Message
Shifting Comparable
Modified Paths
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaModel.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaParameter.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaModel.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java
Diff
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -24,7 +24,7 @@ import com.thoughtworks.qdox.io.IndentBuffer; -public abstract class AbstractJavaEntity extends AbstractBaseJavaEntity implements Comparable, JavaModel { +public abstract class AbstractJavaEntity extends AbstractBaseJavaEntity implements JavaModel { private List<String> modifiers = new LinkedList<String>(); private JavaClass parentClass;
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaModel.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaModel.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/AbstractJavaModel.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -1,12 +1,10 @@ package com.thoughtworks.qdox.model; -import java.io.Serializable; - import com.thoughtworks.qdox.io.DefaultModelWriter; import com.thoughtworks.qdox.io.ModelWriter; import com.thoughtworks.qdox.io.ModelWriterFactory; -public abstract class AbstractJavaModel implements JavaModel, Serializable { +public abstract class AbstractJavaModel implements JavaModel { private ModelWriterFactory modelWriterFactory; private JavaSource source;
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaClass.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -163,11 +163,10 @@ */ public List<JavaClass> getImplementedInterfaces() { List<JavaClass> result = new LinkedList<JavaClass>(); - - for (Type type : getImplements()) { - result.add(type.getJavaClass()); + for ( Type implType : getImplements() ) + { + result.add( implType.getJavaClass() ); } - return result; } @@ -201,7 +200,10 @@ } public void setSuperClass(Type type) { - if (isEnum) throw new IllegalArgumentException("enums cannot extend other classes"); + if (isEnum) + { + throw new IllegalArgumentException("enums cannot extend other classes"); + } superClass = type; } @@ -273,8 +275,8 @@ * @see com.thoughtworks.qdox.model.JavaClass#getPackageName() */ public String getPackageName() { - JavaPackage javaPackage = getPackage(); - return (javaPackage != null && javaPackage.getName() != null) ? javaPackage.getName() : ""; + JavaPackage pckg = getPackage(); + return ( pckg != null && pckg.getName() != null ) ? pckg.getName() : ""; } /* (non-Javadoc)
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -12,12 +12,6 @@ extends AbstractBaseMethod implements JavaConstructor { - public int compareTo( Object o ) - { - // TODO Auto-generated method stub - return 0; - } - public boolean signatureMatches( List<Type> parameterTypes ) { return signatureMatches( parameterTypes, false ); @@ -33,6 +27,7 @@ return getModelWriter().writeConstructor( this ).toString(); } + @Override public String toString() { StringBuffer result = new StringBuffer(); if(isPrivate()) { @@ -68,9 +63,14 @@ return result.toString(); } - /* (non-Javadoc) - * @see com.thoughtworks.qdox.model.JavaMethod#equals(java.lang.Object) - */ + @Override + public int hashCode() { + int hashCode = getName().hashCode(); + hashCode *= getParameters().size(); + return hashCode; + } + + @Override public boolean equals(Object obj) { if (this == obj) { @@ -101,10 +101,20 @@ } return this.varArgs == c.isVarArgs(); } - - public int hashCode() { - int hashCode = getName().hashCode(); - hashCode *= getParameters().size(); - return hashCode; + + public int compareTo( JavaConstructor o ) + { + int result = getName().compareTo( o.getName() ); + if( result == 0 ) + { + int lhs = getParameters().size(); + int rhs = o.getParameters().size(); + result = ((lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0)); + } + for ( int index = 0; result ==0 && index < getParameters().size(); index++ ) + { + result = getParameters().get( index ).compareTo( o.getParameters().get( index ) ); + } + return result; } }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -243,8 +243,8 @@ return Introspector.decapitalize(getName().substring(start)); } - public int compareTo(Object o) { - return getDeclarationSignature(false).compareTo(((JavaMethod)o).getDeclarationSignature(false)); + public int compareTo(JavaMethod o) { + return getDeclarationSignature(false).compareTo(o.getDeclarationSignature(false)); } public String toString() {
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaParameter.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaParameter.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaParameter.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -21,7 +21,8 @@ import java.io.Serializable; -public class DefaultJavaParameter extends AbstractBaseJavaEntity implements Serializable, JavaParameter { +public class DefaultJavaParameter extends AbstractBaseJavaEntity implements JavaParameter +{ private String name; private Type type; @@ -59,24 +60,8 @@ public Type getType() { return type; } - - /* (non-Javadoc) - * @see com.thoughtworks.qdox.model.JavaParameter#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - JavaParameter p = (JavaParameter) obj; - // name isn't used in equality check. - return getType().equals(p.getType()); - } /* (non-Javadoc) - * @see com.thoughtworks.qdox.model.JavaParameter#hashCode() - */ - public int hashCode() { - return getType().hashCode(); - } - - /* (non-Javadoc) * @see com.thoughtworks.qdox.model.JavaParameter#getParentMethod() */ public JavaMethod getParentMethod() { @@ -102,12 +87,6 @@ return varArgs; } - /* (non-Javadoc) - * @see com.thoughtworks.qdox.model.JavaParameter#toString() - */ - public String toString() { - return getResolvedValue() + " "+ name; - } /* (non-Javadoc) * @see com.thoughtworks.qdox.model.JavaParameter#getResolvedValue() @@ -122,4 +101,27 @@ public String getResolvedGenericValue() { return type.getResolvedGenericValue(getParentMethod().getTypeParameters()); } + + @Override + public int hashCode() { + return getType().hashCode(); + } + + @Override + public boolean equals(Object obj) { + JavaParameter p = (JavaParameter) obj; + // name isn't used in equality check. + return getType().equals(p.getType()); + } + + public int compareTo( JavaParameter o ) + { + return type.compareTo( o ); + } + + @Override + public String toString() { + return getResolvedValue() + " "+ name; + } + }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaClass.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -251,17 +251,60 @@ public List<String> getModifiers(); + /** + * Return <code>true</code> if the class includes the public modifier, <code>false</code> otherwise. + * + * @return <code>true</code> if class the public modifier; <code>false</code> otherwise. + */ public boolean isPublic(); + /** + * Return <code>true</code> if the class includes the protected modifier, <code>false</code> otherwise. + * + * @return <code>true</code> if class the protected modifier; <code>false</code> otherwise. + */ public boolean isProtected(); + /** + * Return <code>true</code> if the class includes the private modifier, <code>false</code> otherwise. + * + * @return <code>true</code> if class the private modifier; <code>false</code> otherwise. + */ public boolean isPrivate(); + /** + * Return <code>true</code> if the class includes the final modifier, <code>false</code> otherwise. + * + * @return <code>true</code> if class the final modifier; <code>false</code> otherwise. + */ public boolean isFinal(); + /** + * Return <code>true</code> if the class includes the static modifier, <code>false</code> otherwise. + * + * @return <code>true</code> if class the static modifier; <code>false</code> otherwise. + */ public boolean isStatic(); + /** + * Return <code>true</code> if the class includes the abstract modifier, <code>false</code> otherwise. + * + * @return <code>true</code> if class the abstract modifier; <code>false</code> otherwise. + */ public boolean isAbstract(); public boolean isPrimitive(); + + /** + * (API description of java.lang.Class.toString()) + * + * Converts the object to a string. + * The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by <code>getName</code>. + * If this <code>Class</code> object represents a primitive type, this method returns the name of the primitive type. + * If this <code>Class</code> object represents void this method returns "void". + * + * @return a string representation of this class object. + */ + @Override + public String toString(); } \ No newline at end of file
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -1,5 +1,6 @@ package com.thoughtworks.qdox.model; +import java.io.Serializable; import java.util.List; /** @@ -8,7 +9,7 @@ * @since 2.0 */ public interface JavaConstructor - extends JavaAnnotatedElement, JavaGenericDeclaration, JavaMember + extends JavaModel, JavaAnnotatedElement, JavaGenericDeclaration, JavaMember, Serializable, Comparable<JavaConstructor> { public List<JavaParameter> getParameters();
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -21,7 +21,7 @@ import java.util.List; -public interface JavaMethod extends JavaAnnotatedElement, JavaMember, JavaModel, JavaGenericDeclaration +public interface JavaMethod extends JavaAnnotatedElement, JavaMember, JavaModel, JavaGenericDeclaration, Comparable<JavaMethod> { /**
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -310,4 +310,9 @@ { return getParameterTypes( false ); } + + public int compareTo( JavaMethod o ) + { + return originalMethod.compareTo( o ); + } }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaModel.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaModel.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaModel.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -19,9 +19,9 @@ * under the License. */ -import java.util.List; +import java.io.Serializable; -public interface JavaModel +public interface JavaModel extends Serializable { public String getCodeBlock();
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java (1156 => 1157)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java 2011-04-07 18:48:50 UTC (rev 1156) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java 2011-04-07 20:37:32 UTC (rev 1157) @@ -25,17 +25,13 @@ * @author Robert Scholte * */ -public interface JavaParameter extends JavaAnnotatedElement +public interface JavaParameter extends JavaAnnotatedElement, Comparable<JavaParameter> { public String getName(); public Type getType(); - public boolean equals( Object obj ); - - public int hashCode(); - public JavaMethod getParentMethod(); public JavaClass getParentClass();
To unsubscribe from this list please visit:
