/** * <p>Determines whether or not specified types satisfy the bounds of their * mapped type variables. When a type parameter extends another (such as * {@code <T, S extends T>}), uses another as a type parameter (such as * {@code <T, S extends Comparable>>}), or otherwise depends on * another type variable to be specified, the dependencies must be included * in {@code typeVarAssigns}.</p> * * @param typeVarAssigns specifies the potential types to be assigned to the * type variables, not {@code null}. * @return whether or not the types can be assigned to their respective type * variables. */ public static boolean typesSatisfyVariables(final Map<TypeVariable<?>, Type> typeVarAssigns) { Validate.notNull(typeVarAssigns, "typeVarAssigns is null"); // all types must be assignable to all the bounds of their mapped // type variable. for (final Map.Entry<TypeVariable<?>, Type> entry : typeVarAssigns.entrySet()) { final TypeVariable<?> typeVar = entry.getKey(); final Type type = entry.getValue(); for (final Type bound : getImplicitBounds(typeVar)) { if (!isAssignable(type, substituteTypeVariables(bound, typeVarAssigns), typeVarAssigns)) { return false; } } } return true; }
toBound = substituteTypeVariables(toBound, typeVarAssigns); toBound = substituteTypeVariables(toBound, typeVarAssigns); if (!isAssignable(type, substituteTypeVariables(toBound, typeVarAssigns), typeVarAssigns)) { return false; if (!isAssignable(substituteTypeVariables(toBound, typeVarAssigns), type, typeVarAssigns)) { return false;
/** * <p>Determines whether or not specified types satisfy the bounds of their * mapped type variables. When a type parameter extends another (such as * {@code <T, S extends T>}), uses another as a type parameter (such as * {@code <T, S extends Comparable>>}), or otherwise depends on * another type variable to be specified, the dependencies must be included * in {@code typeVarAssigns}.</p> * * @param typeVarAssigns specifies the potential types to be assigned to the * type variables, not {@code null}. * @return whether or not the types can be assigned to their respective type * variables. */ public static boolean typesSatisfyVariables(final Map<TypeVariable<?>, Type> typeVarAssigns) { Validate.notNull(typeVarAssigns, "typeVarAssigns is null"); // all types must be assignable to all the bounds of their mapped // type variable. for (final Map.Entry<TypeVariable<?>, Type> entry : typeVarAssigns.entrySet()) { final TypeVariable<?> typeVar = entry.getKey(); final Type type = entry.getValue(); for (final Type bound : getImplicitBounds(typeVar)) { if (!isAssignable(type, substituteTypeVariables(bound, typeVarAssigns), typeVarAssigns)) { return false; } } } return true; }
/** * <p>Determines whether or not specified types satisfy the bounds of their * mapped type variables. When a type parameter extends another (such as * {@code <T, S extends T>}), uses another as a type parameter (such as * {@code <T, S extends Comparable>>}), or otherwise depends on * another type variable to be specified, the dependencies must be included * in {@code typeVarAssigns}.</p> * * @param typeVarAssigns specifies the potential types to be assigned to the * type variables, not {@code null}. * @return whether or not the types can be assigned to their respective type * variables. */ public static boolean typesSatisfyVariables(final Map<TypeVariable<?>, Type> typeVarAssigns) { Validate.notNull(typeVarAssigns, "typeVarAssigns is null"); // all types must be assignable to all the bounds of their mapped // type variable. for (final Map.Entry<TypeVariable<?>, Type> entry : typeVarAssigns.entrySet()) { final TypeVariable<?> typeVar = entry.getKey(); final Type type = entry.getValue(); for (final Type bound : getImplicitBounds(typeVar)) { if (!isAssignable(type, substituteTypeVariables(bound, typeVarAssigns), typeVarAssigns)) { return false; } } } return true; }
/** * <p>Determines whether or not specified types satisfy the bounds of their * mapped type variables. When a type parameter extends another (such as * {@code <T, S extends T>}), uses another as a type parameter (such as * {@code <T, S extends Comparable>>}), or otherwise depends on * another type variable to be specified, the dependencies must be included * in {@code typeVarAssigns}.</p> * * @param typeVarAssigns specifies the potential types to be assigned to the * type variables, not {@code null}. * @return whether or not the types can be assigned to their respective type * variables. */ public static boolean typesSatisfyVariables(final Map<TypeVariable<?>, Type> typeVarAssigns) { Validate.notNull(typeVarAssigns, "typeVarAssigns is null"); // all types must be assignable to all the bounds of their mapped // type variable. for (final Map.Entry<TypeVariable<?>, Type> entry : typeVarAssigns.entrySet()) { final TypeVariable<?> typeVar = entry.getKey(); final Type type = entry.getValue(); for (final Type bound : getImplicitBounds(typeVar)) { if (!isAssignable(type, substituteTypeVariables(bound, typeVarAssigns), typeVarAssigns)) { return false; } } } return true; }
toBound = substituteTypeVariables(toBound, typeVarAssigns); toBound = substituteTypeVariables(toBound, typeVarAssigns); if (!isAssignable(type, substituteTypeVariables(toBound, typeVarAssigns), typeVarAssigns)) { return false; if (!isAssignable(substituteTypeVariables(toBound, typeVarAssigns), type, typeVarAssigns)) { return false;
toBound = substituteTypeVariables(toBound, typeVarAssigns); toBound = substituteTypeVariables(toBound, typeVarAssigns); if (!isAssignable(type, substituteTypeVariables(toBound, typeVarAssigns), typeVarAssigns)) { return false; if (!isAssignable(substituteTypeVariables(toBound, typeVarAssigns), type, typeVarAssigns)) { return false;
toBound = substituteTypeVariables(toBound, typeVarAssigns); toBound = substituteTypeVariables(toBound, typeVarAssigns); if (!isAssignable(type, substituteTypeVariables(toBound, typeVarAssigns), typeVarAssigns)) { return false; if (!isAssignable(substituteTypeVariables(toBound, typeVarAssigns), type, typeVarAssigns)) { return false;