Пример #1
0
 public void testWithMutualRecursiveBoundInTypeVariable() throws Exception {
   ParameterizedType paramType =
       (ParameterizedType)
           new WithGenericBound<String>() {}.getTargetType("withMutualRecursiveBound");
   TypeVariable<?> k = (TypeVariable<?>) paramType.getActualTypeArguments()[0];
   TypeVariable<?> v = (TypeVariable<?>) paramType.getActualTypeArguments()[1];
   assertEquals(Types.newParameterizedType(List.class, v), k.getBounds()[0]);
   assertEquals(Types.newParameterizedType(List.class, k), v.getBounds()[0]);
 }
Пример #2
0
 public void testResolveToGenericArrayType() {
   GenericArrayType arrayType =
       (GenericArrayType) new Holder<List<int[][]>[]>() {}.getContentType();
   ParameterizedType listType = (ParameterizedType) arrayType.getGenericComponentType();
   assertEquals(List.class, listType.getRawType());
   assertEquals(Types.newArrayType(int[].class), listType.getActualTypeArguments()[0]);
 }
Пример #3
0
  static final class NativeTypeVariableEquals<X> {
    static final boolean NATIVE_TYPE_VARIABLE_ONLY =
        !Types.NativeTypeVariableEquals.class.getTypeParameters()[0].equals(
            Types.newArtificialTypeVariable(
                Types.NativeTypeVariableEquals.class, "X", new Type[0]));

    NativeTypeVariableEquals() {}
  }
Пример #4
0
 ParameterizedTypeImpl(@Nullable Type var1, Class<?> var2, Type[] var3) {
   Preconditions.checkNotNull(var2);
   Preconditions.checkArgument(var3.length == var2.getTypeParameters().length);
   Types.disallowPrimitiveType(var3, "type parameter");
   this.ownerType = var1;
   this.rawType = var2;
   this.argumentsList = Types.JavaVersion.CURRENT.usedInGenericType(var3);
 }
Пример #5
0
    public String toString() {
      StringBuilder var1 = new StringBuilder("?");
      Iterator var2 = this.lowerBounds.iterator();

      Type var3;
      while (var2.hasNext()) {
        var3 = (Type) var2.next();
        var1.append(" super ").append(Types.toString(var3));
      }

      var2 = Types.filterUpperBounds(this.upperBounds).iterator();

      while (var2.hasNext()) {
        var3 = (Type) var2.next();
        var1.append(" extends ").append(Types.toString(var3));
      }

      return var1.toString();
    }
Пример #6
0
    public String toString() {
      StringBuilder var1 = new StringBuilder();
      if (this.ownerType != null) {
        var1.append(Types.toString(this.ownerType)).append('.');
      }

      var1.append(this.rawType.getName())
          .append('<')
          .append(
              Types.COMMA_JOINER.join(
                  Iterables.transform(this.argumentsList, Types.TYPE_TO_STRING)))
          .append('>');
      return var1.toString();
    }
Пример #7
0
 public Type[] getBounds() {
   return Types.toArray(this.bounds);
 }
Пример #8
0
 public void testWithRecursiveBoundInTypeVariable() throws Exception {
   TypeVariable<?> typeVariable =
       (TypeVariable<?>) new WithGenericBound<String>() {}.getTargetType("withRecursiveBound");
   assertEquals(Types.newParameterizedType(Enum.class, typeVariable), typeVariable.getBounds()[0]);
 }
Пример #9
0
 WildcardTypeImpl(Type[] var1, Type[] var2) {
   Types.disallowPrimitiveType(var1, "lower bound for wildcard");
   Types.disallowPrimitiveType(var2, "upper bound for wildcard");
   this.lowerBounds = Types.JavaVersion.CURRENT.usedInGenericType(var1);
   this.upperBounds = Types.JavaVersion.CURRENT.usedInGenericType(var2);
 }
Пример #10
0
 public void testGenericArrayType() {
   GenericArray<?> genericArray = new GenericArray<Integer>();
   assertEquals(GenericArray.class.getTypeParameters()[0], genericArray.t);
   assertEquals(Types.newArrayType(genericArray.t), genericArray.array);
 }
Пример #11
0
 public String toString() {
   return Types.toString(this.componentType) + "[]";
 }
Пример #12
0
 public Type[] getActualTypeArguments() {
   return Types.toArray(this.argumentsList);
 }
Пример #13
0
 Type newArrayType(Type var1) {
   return (Type)
       (var1 instanceof Class
           ? Types.getArrayClass((Class) var1)
           : new Types.GenericArrayTypeImpl(var1));
 }
Пример #14
0
 TypeVariableImpl(D var1, String var2, Type[] var3) {
   Types.disallowPrimitiveType(var3, "bound for type variable");
   this.genericDeclaration = (GenericDeclaration) Preconditions.checkNotNull(var1);
   this.name = (String) Preconditions.checkNotNull(var2);
   this.bounds = ImmutableList.copyOf((Object[]) var3);
 }
Пример #15
0
 public String apply(Type var1) {
   return Types.toString(var1);
 }
Пример #16
0
 public Type[] getUpperBounds() {
   return Types.toArray(this.upperBounds);
 }
Пример #17
0
 public Type[] getLowerBounds() {
   return Types.toArray(this.lowerBounds);
 }