예제 #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);
 }