Package java.lang.reflect

Examples of java.lang.reflect.WildcardType


        }
        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


            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

        }
        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);
            } else if (genericType instanceof GenericArrayType) {
                genericType = ((GenericArrayType)genericType).getGenericComponentType();
            }
View Full Code Here

  private static boolean contains(Type containingType, Type containedType)
  {
    if (containingType instanceof WildcardType)
    {
      WildcardType wContainingType = (WildcardType) containingType;
      for (Type upperBound : wContainingType.getUpperBounds())
      {
        if (!isSuperType(upperBound, containedType))
        {
          return false;
        }
      }
      for (Type lowerBound : wContainingType.getLowerBounds())
      {
        if (!isSuperType(containedType, lowerBound))
        {
          return false;
        }
View Full Code Here

          .getActualTypeArguments()), pType.getOwnerType() == null ? pType.getOwnerType()
          : map(pType.getOwnerType()));
    }
    else if (type instanceof WildcardType)
    {
      WildcardType wType = (WildcardType) type;
      return new WildcardTypeImpl(map(wType.getUpperBounds()), map(wType.getLowerBounds()));
    }
    else if (type instanceof GenericArrayType)
    {
      return GenericArrayTypeImpl.createArrayType(map(((GenericArrayType) type)
          .getGenericComponentType()));
View Full Code Here

  @Override
  public boolean equals(Object obj)
  {
    if (!(obj instanceof WildcardType))
      return false;
    WildcardType other = (WildcardType) obj;
    return Arrays.equals(lowerBounds, other.getLowerBounds())
        && Arrays.equals(upperBounds, other.getUpperBounds());
  }
View Full Code Here

      if (mappedType != null) {
        paramType = mappedType;
      }
    }
    if (paramType instanceof WildcardType) {
      WildcardType wildcardType = (WildcardType) paramType;
      Type[] upperBounds = wildcardType.getUpperBounds();
      if (upperBounds != null && upperBounds.length > 0 && !Object.class.equals(upperBounds[0])) {
        paramType = upperBounds[0];
      }
      else {
        Type[] lowerBounds = wildcardType.getLowerBounds();
        if (lowerBounds != null && lowerBounds.length > 0 && !Object.class.equals(lowerBounds[0])) {
          paramType = lowerBounds[0];
        }
      }
    }
View Full Code Here

    if (rhsType instanceof WildcardType) {
      // both the upper and lower bounds of the right-hand side must be
      // completely enclosed in the upper and lower bounds of the left-
      // hand side.
      WildcardType rhsWcType = (WildcardType) rhsType;
      Type[] rUpperBounds = rhsWcType.getUpperBounds();

      if (rUpperBounds.length == 0) {
        rUpperBounds = new Type[] { Object.class };
      }

      Type[] rLowerBounds = rhsWcType.getLowerBounds();

      if (rLowerBounds.length == 0) {
        rLowerBounds = new Type[] { null };
      }
View Full Code Here

        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

    } else if (type instanceof Class && ((Class<?>) type).isArray()) {
      Class<?> c = (Class<?>) type;
      return new GenericArrayTypeImpl(c.getComponentType());

    } 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.