Package java.lang.reflect

Examples of java.lang.reflect.WildcardType


      String typeDescription = "array of " + getTypeDescription(gType.getGenericComponentType());
      return typeDescription;
    }
    else if (type instanceof WildcardType)
    {
      WildcardType wType = (WildcardType) type;
      String typeDescription = "wildcard generic type";

      String upperDesc = getTypeArrayDescription(wType.getUpperBounds());
      String lowerDesc = getTypeArrayDescription(wType.getLowerBounds());

      if (StringUtils.notBlankOrNull(upperDesc))
        typeDescription = typeDescription + " with upper bound " + upperDesc;
      if (StringUtils.notBlankOrNull(lowerDesc))
        typeDescription = typeDescription + " and lower bound " + lowerDesc;
View Full Code Here


        {
            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)
            {
View Full Code Here

                paramClass = (Class) type.getActualTypeArguments()[index];
            }

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

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

                paramClass = (Class) type.getActualTypeArguments()[index];
            }

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

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

      TypeVariable tv = (TypeVariable) type;
      Type[] ts = tv.getBounds();
      if (ts != null && ts.length > 0)
        return getTypeClass(ts[0]);
    } else if (type instanceof WildcardType) {
      WildcardType wt = (WildcardType) type;
      Type[] t_low = wt.getLowerBounds();// 取其下界
      if (t_low.length > 0)
        return getTypeClass(t_low[0]);
      Type[] t_up = wt.getUpperBounds(); // 没有下界?取其上界
      return getTypeClass(t_up[0]);// 最起码有Object作为上界
    }
    return clazz;
  }
View Full Code Here

      ParameterizedType pt = (ParameterizedType) type;
      if (pt.getActualTypeArguments().length <= index) return null;
      return pt.getActualTypeArguments()[index] instanceof ParameterizedType ?
        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;
View Full Code Here

      typeVariablesInProgress.remove(aType); // we have finished working on it

      return tvrt;
    } else if (aType instanceof WildcardType) {
      WildcardType wildType = (WildcardType) aType;
      Type[] lowerBounds = wildType.getLowerBounds();
      Type[] upperBounds = wildType.getUpperBounds();
      ResolvedType bound = null;
      boolean isExtends = lowerBounds.length == 0;
      if (isExtends) {
        bound = fromType(upperBounds[0]);
      } else {
View Full Code Here

                }
                a.append(">;");
            }
            return a.toString();
        } else if (type instanceof WildcardType) {
            WildcardType wt = (WildcardType)type;
            StringBuilder a = new StringBuilder();
            java.lang.reflect.Type[] lowBounds = wt.getLowerBounds();
            java.lang.reflect.Type[] upBounds = wt.getUpperBounds();
            for (java.lang.reflect.Type t : upBounds) {
                a.append("+");
                a.append(getClassCode(t));
            }
            for (java.lang.reflect.Type t : lowBounds) {
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

    } else if (type instanceof GenericArrayType) {
      GenericArrayType g = (GenericArrayType) type;
      return new GenericArrayTypeImpl(g.getGenericComponentType());

    } else if (type instanceof WildcardType) {
      WildcardType w = (WildcardType) type;
      return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());

    } else {
      // type is either serializable as-is or unsupported
      return type;
    }
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.