Title: [1391] trunk/qdox/src/test/java/com/thoughtworks/qdox: Move default implementation of JavaTypeVariable to separate package

Diff

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java (1390 => 1391)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java	2011-10-09 19:19:24 UTC (rev 1390)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java	2011-10-09 19:23:33 UTC (rev 1391)
@@ -42,12 +42,12 @@
 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.model.impl.DefaultJavaAnnotation;
 import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
 import com.thoughtworks.qdox.model.impl.DefaultJavaField;
 import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
 import com.thoughtworks.qdox.model.impl.DefaultJavaSource;
+import com.thoughtworks.qdox.model.impl.DefaultJavaTypeVariable;
 import com.thoughtworks.qdox.parser.structs.AnnoDef;
 import com.thoughtworks.qdox.parser.structs.ClassDef;
 import com.thoughtworks.qdox.parser.structs.FieldDef;
@@ -145,7 +145,7 @@
         
         // typeParameters
         if (def.getTypeParameters() != null) {
-            List<TypeVariable<JavaClass>> typeParams = new LinkedList<TypeVariable<JavaClass>>();
+            List<DefaultJavaTypeVariable<JavaClass>> typeParams = new LinkedList<DefaultJavaTypeVariable<JavaClass>>();
             for(TypeVariableDef typeVariableDef : def.getTypeParameters()) {
                 typeParams.add(createTypeVariable(typeVariableDef, (JavaClass) newClass));
             }
@@ -234,7 +234,7 @@
 
         // typeParameters
         if (def.getTypeParams() != null) {
-            List<TypeVariable<JavaConstructor>> typeParams = new LinkedList<TypeVariable<JavaConstructor>>();
+            List<DefaultJavaTypeVariable<JavaConstructor>> typeParams = new LinkedList<DefaultJavaTypeVariable<JavaConstructor>>();
             for(TypeVariableDef typeVariableDef : def.getTypeParams()) {
                 typeParams.add(createTypeVariable(typeVariableDef, (JavaConstructor) currentConstructor));
             }
@@ -283,7 +283,7 @@
 
         // typeParameters
         if (def.getTypeParams() != null) {
-        	List<TypeVariable<JavaMethod>> typeParams = new LinkedList<TypeVariable<JavaMethod>>();
+        	List<DefaultJavaTypeVariable<JavaMethod>> typeParams = new LinkedList<DefaultJavaTypeVariable<JavaMethod>>();
         	for(TypeVariableDef typeVariableDef : def.getTypeParams()) {
         		typeParams.add(createTypeVariable(typeVariableDef, (JavaMethod) currentMethod));
         	}
@@ -308,13 +308,13 @@
         currentMethod.setSourceCode(def.getBody());
     }
 
-    private <G extends JavaGenericDeclaration> TypeVariable<G> createTypeVariable( TypeVariableDef typeVariableDef, G genericDeclaration)
+    private <G extends JavaGenericDeclaration> DefaultJavaTypeVariable<G> createTypeVariable( TypeVariableDef typeVariableDef, G genericDeclaration)
     {
         if ( typeVariableDef == null )
         {
             return null;
         }
-        TypeVariable<G> result = new TypeVariable<G>( null, typeVariableDef.getName(), genericDeclaration );
+        DefaultJavaTypeVariable<G> result = new DefaultJavaTypeVariable<G>( null, typeVariableDef.getName(), genericDeclaration );
 
         if ( typeVariableDef.getBounds() != null && !typeVariableDef.getBounds().isEmpty() )
         {

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java (1390 => 1391)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java	2011-10-09 19:19:24 UTC (rev 1390)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Type.java	2011-10-09 19:23:33 UTC (rev 1391)
@@ -27,6 +27,7 @@
 
 import com.thoughtworks.qdox.library.ClassLibrary;
 import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
+import com.thoughtworks.qdox.model.impl.DefaultJavaTypeVariable;
 
 public class Type implements JavaClass, JavaType, JavaParameterizedType, Serializable {
 
@@ -482,7 +483,7 @@
         for ( Object typeVariable : declaringClass.getTypeParameters() )
         {
             typeIndex++;
-            if ( ((TypeVariable<?>) typeVariable).getFullyQualifiedName().equals( fqn ) )
+            if ( ((DefaultJavaTypeVariable<?>) typeVariable).getFullyQualifiedName().equals( fqn ) )
             {
                 return typeIndex;
             }

Deleted: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java (1390 => 1391)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java	2011-10-09 19:19:24 UTC (rev 1390)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java	2011-10-09 19:23:33 UTC (rev 1391)
@@ -1,148 +0,0 @@
-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.Iterator;
-import java.util.List;
-
-/**
- * @author Robert Scholte
- * @since 1.10
- */
-public class TypeVariable<D extends JavaGenericDeclaration>
-    extends Type implements JavaTypeVariable<D>
-{
-
-    private List<JavaType> bounds;
-    
-    private D genericDeclaration;
-
-    public TypeVariable( String fullName, String name, D genericDeclaration )
-    {
-        super( fullName, name, 0, getContext( genericDeclaration ) );
-        this.genericDeclaration = genericDeclaration;
-    }
-
-    private static JavaClass getContext( JavaGenericDeclaration genericDeclaration )
-    {
-        JavaClass result;
-        if ( genericDeclaration instanceof JavaClass )
-        {
-            result = (JavaClass) genericDeclaration;
-        }
-        else if ( genericDeclaration instanceof JavaMethod )
-        {
-            result = ( (JavaMethod) genericDeclaration ).getDeclaringClass();
-        }
-        else if ( genericDeclaration instanceof JavaConstructor )
-        {
-            result = ( (JavaConstructor) genericDeclaration ).getDeclaringClass();
-        }
-        else
-        {
-            throw new IllegalArgumentException( "Unknown GenericDeclatation implementation" );
-        }
-        return result;
-    }
-
-    /**
-     * @return the bounds
-     */
-    public List<JavaType> getBounds()
-    {
-        return bounds;
-    }
-
-    /**
-     * @param bounds the bounds to set
-     */
-    public void setBounds( List<JavaType> bounds )
-    {
-        this.bounds = bounds;
-    }
-    
-    public D getGenericDeclaration()
-    {
-        return genericDeclaration;
-    }
-
-    @Override
-    public String getFullyQualifiedName()
-    {
-        return super.getValue();
-    }
-
-    @Override
-    public String getGenericFullyQualifiedName()
-    {
-        StringBuffer result = new StringBuffer( super.getFullyQualifiedName() );
-        if ( bounds != null && !bounds.isEmpty() )
-        {
-            result.append( " extends " );
-            for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
-            {
-                result.append( iter.next().getGenericFullyQualifiedName() );
-                if ( iter.hasNext() )
-                {
-                    result.append( "," );
-                }
-            }
-        }
-        return result.toString();
-    }
-
-    public String getValue()
-    {
-        return super.getValue();
-    }
-
-    public String getGenericValue()
-    {
-        StringBuffer result = new StringBuffer( super.getValue() );
-        if ( bounds != null && !bounds.isEmpty() )
-        {
-            result.append( " extends " );
-            for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
-            {
-                result.append( iter.next().getGenericValue() );
-                if ( iter.hasNext() )
-                {
-                    result.append( "," );
-                }
-            }
-        }
-        return result.toString();
-    }
-
-    public String getName()
-    {
-        return super.getValue();
-    }
-
-    public String getResolvedValue()
-    {
-        return bounds.get( 0 ).getValue();
-    }
-
-    public String getResolvedFullyQualifiedName()
-    {
-        return bounds.get( 0 ).getFullyQualifiedName();
-    }
-}

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaClass.java (1390 => 1391)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaClass.java	2011-10-09 19:19:24 UTC (rev 1390)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaClass.java	2011-10-09 19:23:33 UTC (rev 1391)
@@ -42,7 +42,6 @@
 import com.thoughtworks.qdox.model.JavaSource;
 import com.thoughtworks.qdox.model.JavaType;
 import com.thoughtworks.qdox.model.Type;
-import com.thoughtworks.qdox.model.TypeVariable;
 
 /**
  * @author <a href="" Walnes</a>
@@ -60,7 +59,7 @@
 
     private T superClass;
     private List<T> implementz = new LinkedList<T>();
-    private List<TypeVariable<JavaClass>> typeParameters = new LinkedList<TypeVariable<JavaClass>>(); 
+    private List<DefaultJavaTypeVariable<JavaClass>> typeParameters = new LinkedList<DefaultJavaTypeVariable<JavaClass>>(); 
     
     //sourceless class can use this property
 	private JavaPackage javaPackage;
@@ -240,12 +239,12 @@
     /* (non-Javadoc)
      * @see com.thoughtworks.qdox.model.JavaClass#getTypeParameters()
      */
-    public List<TypeVariable<JavaClass>> getTypeParameters()
+    public List<DefaultJavaTypeVariable<JavaClass>> getTypeParameters()
     {
         return typeParameters;
     }
     
-    public void setTypeParameters( List<TypeVariable<JavaClass>> typeParameters )
+    public void setTypeParameters( List<DefaultJavaTypeVariable<JavaClass>> typeParameters )
     {
         this.typeParameters = typeParameters;
     }

Copied: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeVariable.java (from rev 1370, trunk/qdox/src/main/java/com/thoughtworks/qdox/model/TypeVariable.java) (0 => 1391)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeVariable.java	                        (rev 0)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeVariable.java	2011-10-09 19:23:33 UTC (rev 1391)
@@ -0,0 +1,156 @@
+package com.thoughtworks.qdox.model.impl;
+
+/*
+ * 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.Iterator;
+import java.util.List;
+
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaConstructor;
+import com.thoughtworks.qdox.model.JavaGenericDeclaration;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaType;
+import com.thoughtworks.qdox.model.JavaTypeVariable;
+import com.thoughtworks.qdox.model.Type;
+
+/**
+ * @author Robert Scholte
+ * @since 1.10
+ */
+public class DefaultJavaTypeVariable<D extends JavaGenericDeclaration>
+    extends Type implements JavaTypeVariable<D>
+{
+
+    private List<JavaType> bounds;
+    
+    private D genericDeclaration;
+
+    public DefaultJavaTypeVariable( String fullName, String name, D genericDeclaration )
+    {
+        super( fullName, name, 0, getContext( genericDeclaration ) );
+        this.genericDeclaration = genericDeclaration;
+    }
+
+    private static JavaClass getContext( JavaGenericDeclaration genericDeclaration )
+    {
+        JavaClass result;
+        if ( genericDeclaration instanceof JavaClass )
+        {
+            result = (JavaClass) genericDeclaration;
+        }
+        else if ( genericDeclaration instanceof JavaMethod )
+        {
+            result = ( (JavaMethod) genericDeclaration ).getDeclaringClass();
+        }
+        else if ( genericDeclaration instanceof JavaConstructor )
+        {
+            result = ( (JavaConstructor) genericDeclaration ).getDeclaringClass();
+        }
+        else
+        {
+            throw new IllegalArgumentException( "Unknown GenericDeclatation implementation" );
+        }
+        return result;
+    }
+
+    /**
+     * @return the bounds
+     */
+    public List<JavaType> getBounds()
+    {
+        return bounds;
+    }
+
+    /**
+     * @param bounds the bounds to set
+     */
+    public void setBounds( List<JavaType> bounds )
+    {
+        this.bounds = bounds;
+    }
+    
+    public D getGenericDeclaration()
+    {
+        return genericDeclaration;
+    }
+
+    @Override
+    public String getFullyQualifiedName()
+    {
+        return super.getValue();
+    }
+
+    @Override
+    public String getGenericFullyQualifiedName()
+    {
+        StringBuffer result = new StringBuffer( super.getFullyQualifiedName() );
+        if ( bounds != null && !bounds.isEmpty() )
+        {
+            result.append( " extends " );
+            for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
+            {
+                result.append( iter.next().getGenericFullyQualifiedName() );
+                if ( iter.hasNext() )
+                {
+                    result.append( "," );
+                }
+            }
+        }
+        return result.toString();
+    }
+
+    public String getValue()
+    {
+        return super.getValue();
+    }
+
+    public String getGenericValue()
+    {
+        StringBuffer result = new StringBuffer( super.getValue() );
+        if ( bounds != null && !bounds.isEmpty() )
+        {
+            result.append( " extends " );
+            for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
+            {
+                result.append( iter.next().getGenericValue() );
+                if ( iter.hasNext() )
+                {
+                    result.append( "," );
+                }
+            }
+        }
+        return result.toString();
+    }
+
+    public String getName()
+    {
+        return super.getValue();
+    }
+
+    public String getResolvedValue()
+    {
+        return bounds.get( 0 ).getValue();
+    }
+
+    public String getResolvedFullyQualifiedName()
+    {
+        return bounds.get( 0 ).getFullyQualifiedName();
+    }
+}

Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java (1390 => 1391)

--- trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java	2011-10-09 19:19:24 UTC (rev 1390)
+++ trunk/qdox/src/test/java/com/thoughtworks/qdox/JSR14Test.java	2011-10-09 19:23:33 UTC (rev 1391)
@@ -15,7 +15,7 @@
 import com.thoughtworks.qdox.model.JavaType;
 import com.thoughtworks.qdox.model.JavaTypeVariable;
 import com.thoughtworks.qdox.model.Type;
-import com.thoughtworks.qdox.model.TypeVariable;
+import com.thoughtworks.qdox.model.impl.DefaultJavaTypeVariable;
 /**
  * QDOX-54 Support for retrieval of generic type information (JSR 14)
  * 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to