Package java.lang.reflect

Examples of java.lang.reflect.WildcardType


    } else if (a instanceof WildcardType) {
      if (!(b instanceof WildcardType)) {
        return false;
      }

      WildcardType wa = (WildcardType) a;
      WildcardType wb = (WildcardType) b;
      return Arrays.equals(wa.getUpperBounds(), wb.getUpperBounds())
          && Arrays.equals(wa.getLowerBounds(), wb.getLowerBounds());

    } else if (a instanceof TypeVariable) {
      if (!(b instanceof TypeVariable)) {
        return false;
      }
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

      return new GenericArrayTypeInformation((GenericArrayType) fieldType, this, variableMap);
    }

    if (fieldType instanceof WildcardType) {

      WildcardType wildcardType = (WildcardType) fieldType;
      Type[] bounds = wildcardType.getLowerBounds();

      if (bounds.length > 0) {
        return createInfo(bounds[0]);
      }

      bounds = wildcardType.getUpperBounds();

      if (bounds.length > 0) {
        return createInfo(bounds[0]);
      }
    }
View Full Code Here

            }
         }
      }
      if (type1 instanceof WildcardType)
      {
         WildcardType wildcardType = (WildcardType) type1;
         if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds()))
         {
            return true;
         }
      }
      if (type2 instanceof WildcardType)
      {
         WildcardType wildcardType = (WildcardType) type2;
         if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds()))
         {
            return true;
         }
      }
      if (type1 instanceof TypeVariable<?>)
View Full Code Here

            }
         }
      }
      if (type1 instanceof WildcardType)
      {
         WildcardType wildcardType = (WildcardType) type1;
         if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds()))
         {
            return true;
         }
      }
      if (type2 instanceof WildcardType)
      {
         WildcardType wildcardType = (WildcardType) type2;
         if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds()))
         {
            return true;
         }
      }
      if (type1 instanceof TypeVariable<?>)
View Full Code Here

        assertThat(type, instanceOf(java.lang.reflect.ParameterizedType.class));
        java.lang.reflect.Type p =
            ((java.lang.reflect.ParameterizedType) type).getActualTypeArguments()[0];

        assertThat(p, instanceOf(WildcardType.class));
        WildcardType w = (WildcardType) p;

        assertThat(w.getLowerBounds().length, is(0));
        assertThat(w.getUpperBounds().length, is(1));
        assertThat(w.getUpperBounds()[0], is((java.lang.reflect.Type) Object.class));
    }
View Full Code Here

        assertThat(type, instanceOf(java.lang.reflect.ParameterizedType.class));
        java.lang.reflect.Type p =
            ((java.lang.reflect.ParameterizedType) type).getActualTypeArguments()[0];

        assertThat(p, instanceOf(WildcardType.class));
        WildcardType w = (WildcardType) p;

        assertThat(w.getLowerBounds().length, is(0));
        assertThat(w.getUpperBounds().length, is(1));
        assertThat(w.getUpperBounds()[0], is((java.lang.reflect.Type) CharSequence.class));
    }
View Full Code Here

        assertThat(type, instanceOf(java.lang.reflect.ParameterizedType.class));
        java.lang.reflect.Type p =
            ((java.lang.reflect.ParameterizedType) type).getActualTypeArguments()[0];

        assertThat(p, instanceOf(WildcardType.class));
        WildcardType w = (WildcardType) p;

        assertThat(w.getLowerBounds().length, is(1));
        assertThat(w.getLowerBounds()[0], is((java.lang.reflect.Type) CharSequence.class));
        assertThat(w.getUpperBounds().length, is(1));
        assertThat(w.getUpperBounds()[0], is((java.lang.reflect.Type) Object.class));
    }
View Full Code Here

    } else if (type instanceof GenericArrayType) {
      GenericArrayType actualType = (GenericArrayType) type;
      Class<?> rawClass = toRawClass(actualType.getGenericComponentType());
      return wrapWithArray(rawClass);
    } else if (type instanceof WildcardType) {
      WildcardType castedType = (WildcardType) type;
      return toRawClass(castedType.getUpperBounds()[0]);
    } else {
      throw new IllegalArgumentException("Type \'" + type + "\' is not a Class, "
          + "ParameterizedType, or GenericArrayType. Can't extract class.");
    }
  }
View Full Code Here

        throw new UnsupportedOperationException("Expecting parameterized type, got " + parentType
            + ".\n Are you missing the use of TypeToken idiom?\n See "
            + "http://sites.google.com/site/gson/gson-user-guide#TOC-Serializing-and-Deserializing-Gener");
      }
    } else if (typeToEvaluate instanceof WildcardType) {
      WildcardType castedType = (WildcardType) typeToEvaluate;
      return getActualType(castedType.getUpperBounds()[0], parentType, rawParentClass);
    } else {
      throw new IllegalArgumentException("Type \'" + typeToEvaluate + "\' is not a Class, "
          + "ParameterizedType, GenericArrayType or TypeVariable. Can't extract 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.