Examples of TypeVariable


Examples of com.thoughtworks.qdox.model.TypeVariable

            // is generic?
            if ( javaMethod.getTypeParameters() != null )
            {
                for ( int i = 0; i < javaMethod.getTypeParameters().length; i++ )
                {
                    TypeVariable typeParam = javaMethod.getTypeParameters()[i];

                    separatorAdded = appendDefaultParamTag( sb, indent, separatorAdded, typeParam );
                }
            }
        }
View Full Code Here

Examples of com.thoughtworks.qdox.model.TypeVariable

                // is generic?
                if ( javaMethod.getTypeParameters() != null )
                {
                    for ( int i = 0; i < javaMethod.getTypeParameters().length; i++ )
                    {
                        TypeVariable typeParam = javaMethod.getTypeParameters()[i];

                        if ( javaEntityTags.getJavadocParamTag( "<" + typeParam.getName() + ">", true ) == null )
                        {
                            appendDefaultParamTag( sb, indent, typeParam );
                        }
                    }
                }
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.TypeVariable

        }
        result = new SourceVariable(vb.getName(), vb, method.equals(declaredIn));
      }
      else if(binding instanceof ITypeBinding) {
        ITypeBinding tb = (ITypeBinding) binding;
        result = new TypeVariable(tb);
      }
      else
        throw new IllegalArgumentException("Not a variable: " + binding);
      variables.put(binding, result);
    }
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.TypeVariable

        }
        result = new SourceVariable(vb.getName(), vb, method.equals(declaredIn));
      }
      else if(binding instanceof ITypeBinding) {
        ITypeBinding tb = (ITypeBinding) binding;
        result = new TypeVariable(tb);
      }
      else
        throw new IllegalArgumentException("Not a variable: " + binding);
      variables.put(binding, result);
    }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

      return typeDescription;
    }
    else if (type instanceof TypeVariable)
    {
      TypeVariable tType = (TypeVariable) type;
      String typeDescription = "type variable named " + tType.getName();

      typeDescription = typeDescription + " bounded by " + getTypeArrayDescription(tType.getBounds());
      return typeDescription;
    }
    return "Unknown";

  }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

         final Class<?> componentRawType = getRawType(genericArrayType.getGenericComponentType());
         return Array.newInstance(componentRawType, 0).getClass();
      }
      else if (type instanceof TypeVariable)
      {
         final TypeVariable typeVar = (TypeVariable) type;
         if (typeVar.getBounds() != null && typeVar.getBounds().length > 0)
         {
            return getRawType(typeVar.getBounds()[0]);
         }
      }
      throw new RuntimeException("Unable to determine base class from Type");
   }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

        getConcreteGeneric(pt.getRawType(), 0) : getConcreteGeneric(pt.getActualTypeArguments()[index], 0);
    } else if (type instanceof WildcardType) {
      WildcardType wt = (WildcardType) type;
      return wt.getUpperBounds().length <= index ? null : getConcreteGeneric(wt.getUpperBounds()[index], 0);
    } else if (type instanceof TypeVariable) {
      TypeVariable tt = (TypeVariable) type;
      return tt.getBounds().length <= index ? null : getConcreteGeneric(tt.getBounds()[index], 0);
    } else if (type instanceof GenericArrayType) {
      GenericArrayType gat = (GenericArrayType) type;
      return getConcreteGeneric(gat.getGenericComponentType(), index);
    } else if (type instanceof Class) {
      return (Class) type;
View Full Code Here

Examples of java.lang.reflect.TypeVariable

            if (superType instanceof ParameterizedType)
            {
                ParameterizedType superPType = (ParameterizedType) superType;

                TypeVariable tv = (TypeVariable) genericType;

                String name = tv.getName();

                TypeVariable[] typeVariables = tv.getGenericDeclaration().getTypeParameters();

                for (int i = 0; i < typeVariables.length; i++)
                {
                    TypeVariable stv = typeVariables[i];

                    // We're trying to match the name of the type variable that is used as the return type
                    // of the method. With that name, we find the corresponding index in the
                    // type declarations. With the index, we check superPType for the Class instance
                    // that defines it. Generics has lots of other options that we simply can't handle.

                    if (stv.getName().equals(name))
                    {
                        Type actualType = superPType.getActualTypeArguments()[i];

                        if (actualType instanceof Class)
                            return (Class) actualType;
View Full Code Here

Examples of java.lang.reflect.TypeVariable

  Type resolveType(Type toResolve) {
    // this implementation is made a little more complicated in an attempt to avoid object-creation
    while (true) {
      if (toResolve instanceof TypeVariable) {
        TypeVariable original = (TypeVariable) toResolve;
        toResolve = MoreTypes.resolveTypeVariable(type, rawType, original);
        if (toResolve == original) {
          return toResolve;
        }

      } else if (toResolve instanceof GenericArrayType) {
        GenericArrayType original = (GenericArrayType) toResolve;
        Type componentType = original.getGenericComponentType();
        Type newComponentType = resolveType(componentType);
        return componentType == newComponentType
            ? original
            : Types.arrayOf(newComponentType);

      } else if (toResolve instanceof ParameterizedType) {
        ParameterizedType original = (ParameterizedType) toResolve;
        Type ownerType = original.getOwnerType();
        Type newOwnerType = resolveType(ownerType);
        boolean changed = newOwnerType != ownerType;

        Type[] args = original.getActualTypeArguments();
        for (int t = 0, length = args.length; t < length; t++) {
          Type resolvedTypeArgument = resolveType(args[t]);
          if (resolvedTypeArgument != args[t]) {
            if (!changed) {
              args = args.clone();
              changed = true;
            }
            args[t] = resolvedTypeArgument;
          }
        }

        return changed
            ? Types.newParameterizedTypeWithOwner(newOwnerType, original.getRawType(), args)
            : original;

      } else if (toResolve instanceof WildcardType) {
        WildcardType original = (WildcardType) toResolve;
        Type[] originalLowerBound = original.getLowerBounds();
        Type[] originalUpperBound = original.getUpperBounds();

        if (originalLowerBound.length == 1) {
          Type lowerBound = resolveType(originalLowerBound[0]);
          if (lowerBound != originalLowerBound[0]) {
            return Types.supertypeOf(lowerBound);
View Full Code Here

Examples of java.lang.reflect.TypeVariable

                ParameterizedType pt = (ParameterizedType)t;
                Type[] args = pt.getActualTypeArguments();
                for (int i = 0; i < args.length; i++) {
                    Type arg = args[i];
                    if (arg instanceof TypeVariable) {
                        TypeVariable var = (TypeVariable)arg;
                        Type[] bounds = var.getBounds();
                        boolean isResolved = false;
                        for (int j = 0; j < bounds.length; j++) {
                            Class<?> cls = InjectionUtils.getRawType(bounds[j]);
                            if (cls != null && cls.isAssignableFrom(expectedType)) {
                                isResolved = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.