- Revision
- 1370
- Author
- rfscholte
- Date
- 2011-10-03 14:41:43 -0500 (Mon, 03 Oct 2011)
Log Message
Introducing JavaTypeVariable
Modified Paths
- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.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/JavaGenericDeclaration.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java
- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java
- trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java
Added Paths
Diff
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -43,6 +43,7 @@ import com.thoughtworks.qdox.model.JavaMethod; import com.thoughtworks.qdox.model.JavaParameter; import com.thoughtworks.qdox.model.JavaSource; +import com.thoughtworks.qdox.model.JavaType; import com.thoughtworks.qdox.model.Type; import com.thoughtworks.qdox.model.TypeVariable; import com.thoughtworks.qdox.parser.structs.AnnoDef; @@ -315,7 +316,7 @@ if ( typeVariableDef.getBounds() != null && !typeVariableDef.getBounds().isEmpty() ) { - List<Type> bounds = new LinkedList<Type>(); + List<JavaType> bounds = new LinkedList<JavaType>(); for ( TypeDef typeDef : typeVariableDef.getBounds() ) { bounds.add( createType( typeDef, 0 ) );
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaConstructor.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -13,14 +13,14 @@ extends AbstractBaseMethod<T> implements JavaConstructor { - private List<TypeVariable<JavaConstructor>> typeParameters = Collections.emptyList(); + private List<JavaTypeVariable<JavaConstructor>> typeParameters = Collections.emptyList(); - public void setTypeParameters( List<TypeVariable<JavaConstructor>> typeParameters ) + public void setTypeParameters( List<JavaTypeVariable<JavaConstructor>> typeParameters ) { this.typeParameters = typeParameters; } - public List<TypeVariable<JavaConstructor>> getTypeParameters() + public List<JavaTypeVariable<JavaConstructor>> getTypeParameters() { return typeParameters; }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/DefaultJavaMethod.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -28,7 +28,7 @@ public class DefaultJavaMethod<T extends JavaClass & JavaParameterizedType> extends AbstractBaseMethod<T> implements JavaMethod { private T returns = (T) Type.VOID; - private List<TypeVariable<JavaMethod>> typeParameters = Collections.emptyList(); + private List<JavaTypeVariable<JavaMethod>> typeParameters = Collections.emptyList(); /** * The default constructor @@ -63,12 +63,12 @@ return returns; } - public void setTypeParameters( List<TypeVariable<JavaMethod>> typeParameters ) + public void setTypeParameters( List<JavaTypeVariable<JavaMethod>> typeParameters ) { this.typeParameters = typeParameters; } - public List<TypeVariable<JavaMethod>> getTypeParameters() + public List<JavaTypeVariable<JavaMethod>> getTypeParameters() { return typeParameters; } @@ -356,8 +356,8 @@ result.append( "," ); } JavaType originalType = getParameters().get( paramIndex ).getType(); - TypeVariable typeVariable = Type.resolve( originalType, getTypeParameters() ); - result.append( typeVariable == null ? originalType.getFullyQualifiedName() : typeVariable.getResolvedFullyQualifiedName() ); + JavaTypeVariable<?> typeVariable = Type.resolve( originalType, getTypeParameters() ); + result.append( typeVariable == null ? originalType.getFullyQualifiedName() : typeVariable.getBounds().get( 0 ).getFullyQualifiedName() ); } result.append( ")" ); if ( getExceptions().size() > 0 )
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -35,5 +35,5 @@ * * @return a list of typeParameters, never <code>null</code> */ - <D extends JavaGenericDeclaration> List<TypeVariable<D>> getTypeParameters(); + <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters(); }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -211,7 +211,7 @@ return originalMethod.getTagsByName( name ); } - public List<TypeVariable<JavaMethod>> getTypeParameters() + public List<JavaTypeVariable<JavaMethod>> getTypeParameters() { return originalMethod.getTypeParameters(); }
Added: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaTypeVariable.java (0 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaTypeVariable.java (rev 0) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/JavaTypeVariable.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -0,0 +1,32 @@ +package com.thoughtworks.qdox.model; + + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +public interface JavaTypeVariable<D extends JavaGenericDeclaration> extends JavaType +{ + D getGenericDeclaration(); + + String getName(); + + List<JavaType> getBounds(); +} \ No newline at end of file
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -166,7 +166,7 @@ return result.toString(); } - protected static <D extends JavaGenericDeclaration> String getGenericValue( JavaType base, List<TypeVariable<D>> typeVariableList ) + protected static <D extends JavaGenericDeclaration> String getGenericValue( JavaType base, List<JavaTypeVariable<D>> typeVariableList ) { StringBuffer result = new StringBuffer( getResolvedValue( base, typeVariableList ) ); for ( Iterator<JavaType> iter = getActualTypeArguments( base ).iterator(); iter.hasNext(); ) @@ -194,10 +194,10 @@ return result; } - protected static <D extends JavaGenericDeclaration> String getResolvedValue( JavaType base, List<TypeVariable<D>> typeParameters ) + protected static <D extends JavaGenericDeclaration> String getResolvedValue( JavaType base, List<JavaTypeVariable<D>> typeParameters ) { String result = base.getValue(); - for ( TypeVariable<?> typeParameter : typeParameters ) + for ( JavaTypeVariable<?> typeParameter : typeParameters ) { if ( typeParameter.getName().equals( base.getValue() ) ) { @@ -208,11 +208,11 @@ return result; } - protected static <D extends JavaGenericDeclaration> TypeVariable<D> resolve( JavaType base, List<TypeVariable<D>> typeParameters ) + protected static <D extends JavaGenericDeclaration> JavaTypeVariable<D> resolve( JavaType base, List<JavaTypeVariable<D>> typeParameters ) { - TypeVariable<D> result = null; + JavaTypeVariable<D> result = null; // String result = getGenericValue(typeParameters); - for ( TypeVariable<D> typeParameter : typeParameters ) + for ( JavaTypeVariable<D> typeParameter : typeParameters ) { if ( typeParameter.getName().equals( base.getValue() ) ) { @@ -543,10 +543,10 @@ return result.toString(); } - protected static <D extends JavaGenericDeclaration> String getResolvedGenericValue( JavaType base, List<TypeVariable<D>> typeParameters ) + protected static <D extends JavaGenericDeclaration> String getResolvedGenericValue( JavaType base, List<JavaTypeVariable<D>> typeParameters ) { StringBuffer result = new StringBuffer(); - TypeVariable<?> variable = resolve( base, typeParameters ); + JavaTypeVariable<?> variable = resolve( base, typeParameters ); result.append( variable == null ? base.getValue() : variable.getBounds().get(0).getValue() ); List<JavaType> actualTypeArguments = getActualTypeArguments( base ); if ( !actualTypeArguments.isEmpty() ) @@ -572,10 +572,10 @@ return result.toString(); } - protected static <D extends JavaGenericDeclaration> String getResolvedGenericFullyQualifiedName( JavaType base, List<TypeVariable<D>> typeParameters ) + protected static <D extends JavaGenericDeclaration> String getResolvedGenericFullyQualifiedName( JavaType base, List<JavaTypeVariable<D>> typeParameters ) { StringBuffer result = new StringBuffer(); - TypeVariable<D> variable = resolve( base, typeParameters ); + JavaTypeVariable<D> variable = resolve( base, typeParameters ); result.append( variable == null ? base.getFullyQualifiedName() : variable.getBounds().get(0).getFullyQualifiedName() ); List<JavaType> actualTypeArguments = getActualTypeArguments( base ); if ( !actualTypeArguments.isEmpty() ) @@ -601,9 +601,9 @@ return result.toString(); } - protected static <D extends JavaGenericDeclaration> String getResolvedFullyQualifiedName( JavaType base, List<TypeVariable<D>> typeParameters ) + protected static <D extends JavaGenericDeclaration> String getResolvedFullyQualifiedName( JavaType base, List<JavaTypeVariable<D>> typeParameters ) { - TypeVariable<D> variable = resolve( base, typeParameters ); + JavaTypeVariable<D> variable = resolve( base, typeParameters ); return (variable == null ? base.getFullyQualifiedName() : variable.getBounds().get(0).getFullyQualifiedName() ); } @@ -766,7 +766,7 @@ * (non-Javadoc) * @see com.thoughtworks.qdox.model.JavaGenericDeclaration#getTypeParameters() */ - public <D extends JavaGenericDeclaration> List<TypeVariable<D>> getTypeParameters() + public <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters() { return resolveRealClass().getTypeParameters(); }
Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java (1369 => 1370)
--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -27,10 +27,10 @@ * @since 1.10 */ public class TypeVariable<D extends JavaGenericDeclaration> - extends Type + extends Type implements JavaTypeVariable<D> { - private List<Type> bounds; + private List<JavaType> bounds; private D genericDeclaration; @@ -65,7 +65,7 @@ /** * @return the bounds */ - public List<Type> getBounds() + public List<JavaType> getBounds() { return bounds; } @@ -73,7 +73,7 @@ /** * @param bounds the bounds to set */ - public void setBounds( List<Type> bounds ) + public void setBounds( List<JavaType> bounds ) { this.bounds = bounds; } @@ -96,7 +96,7 @@ if ( bounds != null && !bounds.isEmpty() ) { result.append( " extends " ); - for ( Iterator<Type> iter = bounds.iterator(); iter.hasNext(); ) + for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); ) { result.append( iter.next().getGenericFullyQualifiedName() ); if ( iter.hasNext() ) @@ -119,7 +119,7 @@ if ( bounds != null && !bounds.isEmpty() ) { result.append( " extends " ); - for ( Iterator<Type> iter = bounds.iterator(); iter.hasNext(); ) + for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); ) { result.append( iter.next().getGenericValue() ); if ( iter.hasNext() ) @@ -145,5 +145,4 @@ { return bounds.get( 0 ).getFullyQualifiedName(); } - }
Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java (1369 => 1370)
--- trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java 2011-10-03 19:02:18 UTC (rev 1369) +++ trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java 2011-10-03 19:41:43 UTC (rev 1370) @@ -8,10 +8,12 @@ import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaField; +import com.thoughtworks.qdox.model.JavaGenericDeclaration; import com.thoughtworks.qdox.model.JavaMethod; import com.thoughtworks.qdox.model.JavaParameter; import com.thoughtworks.qdox.model.JavaSource; import com.thoughtworks.qdox.model.JavaType; +import com.thoughtworks.qdox.model.JavaTypeVariable; import com.thoughtworks.qdox.model.Type; import com.thoughtworks.qdox.model.TypeVariable; /** @@ -386,7 +388,7 @@ JavaSource javaSource = builder.addSource(new StringReader(source)); JavaMethod javaMethod = javaSource.getClasses().get(0).getMethods().get(0); assertEquals( 1, javaMethod.getTypeParameters().size()); - TypeVariable typeVariable = javaMethod.getTypeParameters().get(0); + JavaTypeVariable<JavaGenericDeclaration> typeVariable = javaMethod.getTypeParameters().get(0); assertEquals( "T", typeVariable.getName() ); assertEquals( "T", typeVariable.getFullyQualifiedName()); assertEquals( "T extends java.lang.StringBuffer", typeVariable.getGenericFullyQualifiedName()); @@ -400,14 +402,14 @@ "}"; JavaSource javaSource = builder.addSource(new StringReader(source)); JavaMethod javaMethod = javaSource.getClasses().get(0).getMethods().get(0); - TypeVariable typeVariable0 = javaMethod.getTypeParameters().get(0); + JavaTypeVariable<JavaGenericDeclaration> typeVariable0 = javaMethod.getTypeParameters().get(0); assertEquals("T", typeVariable0.getName()); assertEquals("T", typeVariable0.getFullyQualifiedName()); assertEquals("T", typeVariable0.getGenericFullyQualifiedName()); assertEquals("T", typeVariable0.getValue()); assertEquals("T", typeVariable0.getGenericValue()); - TypeVariable typeVariable1 = javaMethod.getTypeParameters().get(1); + JavaTypeVariable<JavaGenericDeclaration> typeVariable1 = javaMethod.getTypeParameters().get(1); assertEquals("S", typeVariable1.getName()); assertEquals("S", typeVariable1.getFullyQualifiedName()); assertEquals("S extends T", typeVariable1.getGenericFullyQualifiedName());
To unsubscribe from this list please visit:
