/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument( supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }
return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument(supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }
/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument( supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }
/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument( supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
return rawType.getGenericInterfaces()[i]; } else if (toResolve.isAssignableFrom(interfaces[i])) { return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], toResolve); return rawType.getGenericSuperclass(); } else if (toResolve.isAssignableFrom(rawSupertype)) { return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, toResolve);
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
public static Type resolveTypeVariable(Type type, Class<?> rawType, TypeVariable unknown) { Class<?> declaredByRaw = declaringClassOf(unknown); // we can't reduce this further if (declaredByRaw == null) { return unknown; } Type declaredBy = getGenericSupertype(type, rawType, declaredByRaw); if (declaredBy instanceof ParameterizedType) { int index = indexOf(declaredByRaw.getTypeParameters(), unknown); return ((ParameterizedType) declaredBy).getActualTypeArguments()[index]; } return unknown; }
/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument(supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }
/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument(supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }
/** * Returns the generic form of {@code supertype}. For example, if this is {@code * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code * Iterable.class}. * * @param supertype a superclass of, or interface implemented by, this. * @since 2.0 */ public TypeLiteral<?> getSupertype(Class<?> supertype) { checkArgument(supertype.isAssignableFrom(rawType), "%s is not a supertype of %s", supertype, this.type); return resolve(MoreTypes.getGenericSupertype(type, rawType, supertype)); }