/** * Returns the {@link Type} object that represents {@code clazz<T1,T2,T3>}. */ public Type createParameterizedType(Class rawType, Type... arguments) { return new ParameterizedTypeImpl(rawType, arguments, null); }
private static class BinderArg { final TypeVariable[] params; final Type[] args; BinderArg(TypeVariable[] params, Type[] args) { this.params = params; this.args = args; assert params.length == args.length; } public BinderArg(GenericDeclaration decl, Type[] args) { this(decl.getTypeParameters(), args); } Type replace(TypeVariable v) { for (int i = 0; i < params.length; i++) { if (params[i].equals(v)) { return args[i]; } } return v; // this is a free variable } } private static final TypeVisitor<Type, BinderArg> binder = new TypeVisitor<Type, BinderArg>() {
public Type onParameterizdType(ParameterizedType p, BinderArg args) { Type[] params = p.getActualTypeArguments(); boolean different = false; for (int i = 0; i < params.length; i++) { Type t = params[i]; params[i] = visit(t, args); different |= t != params[i]; } Type newOwner = p.getOwnerType(); if (newOwner != null) { newOwner = visit(newOwner, args); } different |= p.getOwnerType() != newOwner; if (!different) { return p; } return new ParameterizedTypeImpl((Class<?>) p.getRawType(), params, newOwner); }
/** * Returns the {@link Type} object that represents {@code clazz<T1,T2,T3>}. */ public Type createParameterizedType(Class rawType, Type... arguments) { return new ParameterizedTypeImpl(rawType, arguments, null); }
private static class BinderArg { final TypeVariable[] params; final Type[] args; BinderArg(TypeVariable[] params, Type[] args) { this.params = params; this.args = args; assert params.length == args.length; } public BinderArg(GenericDeclaration decl, Type[] args) { this(decl.getTypeParameters(), args); } Type replace(TypeVariable v) { for (int i = 0; i < params.length; i++) { if (params[i].equals(v)) { return args[i]; } } return v; // this is a free variable } } private static final TypeVisitor<Type, BinderArg> binder = new TypeVisitor<Type, BinderArg>() {
public Type onParameterizdType(ParameterizedType p, BinderArg args) { Type[] params = p.getActualTypeArguments(); boolean different = false; for (int i = 0; i < params.length; i++) { Type t = params[i]; params[i] = visit(t, args); different |= t != params[i]; } Type newOwner = p.getOwnerType(); if (newOwner != null) { newOwner = visit(newOwner, args); } different |= p.getOwnerType() != newOwner; if (!different) { return p; } return new ParameterizedTypeImpl((Class<?>) p.getRawType(), params, newOwner); }
/** * Returns the {@link Type} object that represents {@code clazz<T1,T2,T3>}. */ public Type createParameterizedType(Class rawType, Type... arguments) { return new ParameterizedTypeImpl(rawType, arguments, null); }
/** * Returns the {@link Type} object that represents {@code clazz<T1,T2,T3>}. */ public Type createParameterizedType(Class rawType, Type... arguments) { return new ParameterizedTypeImpl(rawType, arguments, null); }
/** * Returns the {@link Type} object that represents {@code clazz<T1,T2,T3>}. */ public Type createParameterizedType(Class rawType, Type... arguments) { return new ParameterizedTypeImpl(rawType, arguments, null); }
/** * Returns the {@link Type} object that represents {@code clazz<T1,T2,T3>}. */ public Type createParameterizedType(Class rawType, Type... arguments) { return new ParameterizedTypeImpl(rawType, arguments, null); }
private static class BinderArg { final TypeVariable[] params; final Type[] args; BinderArg(TypeVariable[] params, Type[] args) { this.params = params; this.args = args; assert params.length == args.length; } public BinderArg(GenericDeclaration decl, Type[] args) { this(decl.getTypeParameters(), args); } Type replace(TypeVariable v) { for (int i = 0; i < params.length; i++) { if (params[i].equals(v)) { return args[i]; } } return v; // this is a free variable } } private static final TypeVisitor<Type, BinderArg> binder = new TypeVisitor<Type, BinderArg>() {
private static class BinderArg { final TypeVariable[] params; final Type[] args; BinderArg(TypeVariable[] params, Type[] args) { this.params = params; this.args = args; assert params.length == args.length; } public BinderArg(GenericDeclaration decl, Type[] args) { this(decl.getTypeParameters(), args); } Type replace(TypeVariable v) { for (int i = 0; i < params.length; i++) { if (params[i].equals(v)) { return args[i]; } } return v; // this is a free variable } } private static final TypeVisitor<Type, BinderArg> binder = new TypeVisitor<Type, BinderArg>() {
private static class BinderArg { final TypeVariable[] params; final Type[] args; BinderArg(TypeVariable[] params, Type[] args) { this.params = params; this.args = args; assert params.length == args.length; } public BinderArg(GenericDeclaration decl, Type[] args) { this(decl.getTypeParameters(), args); } Type replace(TypeVariable v) { for (int i = 0; i < params.length; i++) { if (params[i].equals(v)) { return args[i]; } } return v; // this is a free variable } } private static final TypeVisitor<Type, BinderArg> binder = new TypeVisitor<Type, BinderArg>() {
private static class BinderArg { final TypeVariable[] params; final Type[] args; BinderArg(TypeVariable[] params, Type[] args) { this.params = params; this.args = args; assert params.length == args.length; } public BinderArg(GenericDeclaration decl, Type[] args) { this(decl.getTypeParameters(), args); } Type replace(TypeVariable v) { for (int i = 0; i < params.length; i++) { if (params[i].equals(v)) { return args[i]; } } return v; // this is a free variable } } private static final TypeVisitor<Type, BinderArg> binder = new TypeVisitor<Type, BinderArg>() {
public Type onParameterizdType(ParameterizedType p, BinderArg args) { Type[] params = p.getActualTypeArguments(); boolean different = false; for (int i = 0; i < params.length; i++) { Type t = params[i]; params[i] = visit(t, args); different |= t != params[i]; } Type newOwner = p.getOwnerType(); if (newOwner != null) { newOwner = visit(newOwner, args); } different |= p.getOwnerType() != newOwner; if (!different) { return p; } return new ParameterizedTypeImpl((Class<?>) p.getRawType(), params, newOwner); }
public Type onParameterizdType(ParameterizedType p, BinderArg args) { Type[] params = p.getActualTypeArguments(); boolean different = false; for (int i = 0; i < params.length; i++) { Type t = params[i]; params[i] = visit(t, args); different |= t != params[i]; } Type newOwner = p.getOwnerType(); if (newOwner != null) { newOwner = visit(newOwner, args); } different |= p.getOwnerType() != newOwner; if (!different) { return p; } return new ParameterizedTypeImpl((Class<?>) p.getRawType(), params, newOwner); }
public Type onParameterizdType(ParameterizedType p, BinderArg args) { Type[] params = p.getActualTypeArguments(); boolean different = false; for (int i = 0; i < params.length; i++) { Type t = params[i]; params[i] = visit(t, args); different |= t != params[i]; } Type newOwner = p.getOwnerType(); if (newOwner != null) { newOwner = visit(newOwner, args); } different |= p.getOwnerType() != newOwner; if (!different) { return p; } return new ParameterizedTypeImpl((Class<?>) p.getRawType(), params, newOwner); }
public Type onParameterizdType(ParameterizedType p, BinderArg args) { Type[] params = p.getActualTypeArguments(); boolean different = false; for (int i = 0; i < params.length; i++) { Type t = params[i]; params[i] = visit(t, args); different |= t != params[i]; } Type newOwner = p.getOwnerType(); if (newOwner != null) { newOwner = visit(newOwner, args); } different |= p.getOwnerType() != newOwner; if (!different) { return p; } return new ParameterizedTypeImpl((Class<?>) p.getRawType(), params, newOwner); }