Package java.lang.reflect

Examples of java.lang.reflect.WildcardType


    }
    if (type instanceof TypeVariable<?>) {
      return ensureBaseType(((TypeVariable<?>) type).getBounds()[0]);
    }
    if (type instanceof WildcardType) {
      WildcardType wild = (WildcardType) type;
      return ensureBaseType(wild.getUpperBounds()[0]);
    }
    throw new RuntimeException("Cannot handle " + type.getClass().getName());
  }
View Full Code Here


  protected boolean isSimpleWildcardType(Type type)
  {
    if(!(type instanceof WildcardType))
      return false;
   
    WildcardType wt=(WildcardType)type;
   
    Type[] lb=wt.getLowerBounds();
    Type[] ub=wt.getUpperBounds();
   
    if((lb==null ||lb.length==0) && (ub==null || ub.length==0))
      return true;
    else
      return false;
View Full Code Here

            }
        } else if (type instanceof GenericArrayType) {
            GenericArrayType gType = (GenericArrayType)type;
            findClasses(gType, classSet, visited);
        } else if (type instanceof WildcardType) {
            WildcardType wType = (WildcardType)type;
            for (Type t : wType.getLowerBounds()) {
                findClasses(t, classSet, visited);
            }
            for (Type t : wType.getUpperBounds()) {
                findClasses(t, classSet, visited);
            }
        }
    }
View Full Code Here

        }
        if (!ParameterizedType.class.isAssignableFrom(genericType.getClass())) {
            if (genericType instanceof TypeVariable) {
                genericType = getType(((TypeVariable<?>)genericType).getBounds(), pos);
            } else if (genericType instanceof WildcardType) {
                WildcardType wildcardType = (WildcardType)genericType;
                Type[] bounds = wildcardType.getLowerBounds();
                if (bounds.length == 0) {
                    bounds = wildcardType.getUpperBounds();
                }
                genericType = getType(bounds, pos);
            }

            Class<?> cls = (Class<?>)genericType;
View Full Code Here

      TypeVariable<?> aType = (TypeVariable<?>) type;
     
      return createVar(aType, paramMap, paramDeclName, parentType, classFill);
    }
    else if (type instanceof WildcardType) {
      WildcardType aType = (WildcardType) type;

      BaseType []lowerBounds = toBaseType(aType.getLowerBounds(),
                                          paramMap, paramDeclName);
      BaseType []upperBounds = toBaseType(aType.getUpperBounds(),
                                          paramMap, paramDeclName);
     
      return new WildcardTypeImpl(lowerBounds, upperBounds);
    }
   
View Full Code Here

    private Object getGenericComponent(Object genericType, int index) {
        if (genericType instanceof ParameterizedType) {
            ParameterizedType type = (ParameterizedType)genericType;

            if (type.getActualTypeArguments()[index] instanceof WildcardType) {
                WildcardType wildcardType = (WildcardType)type.getActualTypeArguments()[index];

                return wildcardType;
            } else if (type.getActualTypeArguments()[index] instanceof ParameterizedType) {
                ParameterizedType ptype = (ParameterizedType)type.getActualTypeArguments()[index];
View Full Code Here

            ParameterizedType type = (ParameterizedType)genericType;

            if (type.getActualTypeArguments()[index] instanceof Class) {
                paramClass = (Class)type.getActualTypeArguments()[index];
            } else if (type.getActualTypeArguments()[index] instanceof WildcardType) {
                WildcardType wildcardType = (WildcardType)type.getActualTypeArguments()[index];
                // we really aren't prepared to deal with multiple upper bounds,
                // so we just look at the first one.
                if (wildcardType.getUpperBounds()[0] instanceof Class) {
                    paramClass = (Class)wildcardType.getUpperBounds()[0];
                }
            } else if (type.getActualTypeArguments()[index] instanceof ParameterizedType) {
                ParameterizedType ptype = (ParameterizedType)type.getActualTypeArguments()[index];
                paramClass = (Class)ptype.getRawType();
            }
View Full Code Here

                    .getGenericComponentType());
            while ( t instanceof ParameterizedType )
                t = collapse(((ParameterizedType)t).getRawType());
            return Array.newInstance((Class<?>)t, 0).getClass();
        } else if (target instanceof WildcardType) {
            WildcardType wct = (WildcardType) target;
            if (wct.getLowerBounds().length == 0)
                return collapse(wct.getUpperBounds()[0]);
            else
                return collapse(wct.getLowerBounds()[0]);
        }
        throw new RuntimeException("Huh? " + target);
    }
View Full Code Here

          .getGenericComponentType());
      while ( t instanceof ParameterizedType )
        t = collapse(((ParameterizedType)t).getRawType());
      return Array.newInstance((Class<?>)t, 0).getClass();
    } else if (target instanceof WildcardType) {
      WildcardType wct = (WildcardType) target;
      if (wct.getLowerBounds().length == 0)
        return collapse(wct.getUpperBounds()[0]);
      else
        return collapse(wct.getLowerBounds()[0]);
    }
    throw new RuntimeException("Huh? " + target);
  }
View Full Code Here

            return getErasure(arrayType.getGenericComponentType());
        } else if (type instanceof ParameterizedType) {
            ParameterizedType pType = (ParameterizedType)type;
            return getErasure(pType.getRawType());
        } else if (type instanceof WildcardType) {
            WildcardType wType = (WildcardType)type;
            Type[] types = wType.getUpperBounds();
            return getErasure(types[0]);
        } else if (type instanceof TypeVariable) {
            TypeVariable var = (TypeVariable)type;
            Type[] types = var.getBounds();
            return getErasure(types[0]);
View Full Code Here

TOP

Related Classes of java.lang.reflect.WildcardType

Copyright © 2018 www.massapicom. 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.