/** * Assert that {@code superType.isAssignableFrom(subType)} is {@code true}. * <pre class="code">Assert.isAssignable(Number.class, myClass, "Number expected");</pre> * @param superType the super type to check against * @param subType the sub type to check * @param message a message which will be prepended to provide further context. * If it is empty or ends in ":" or ";" or "," or ".", a full exception message * will be appended. If it ends in a space, the name of the offending sub type * will be appended. In any other case, a ":" with a space and the name of the * offending sub type will be appended. * @throws IllegalArgumentException if the classes are not assignable */ public static void isAssignable(Class<?> superType, @Nullable Class<?> subType, String message) { notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, message); } }
/** * Assert that {@code superType.isAssignableFrom(subType)} is {@code true}. * <pre class="code"> * Assert.isAssignable(Number.class, myClass, () -> "Processing " + myAttributeName + ":"); * </pre> * @param superType the super type to check against * @param subType the sub type to check * @param messageSupplier a supplier for the exception message to use if the * assertion fails. See {@link #isAssignable(Class, Class, String)} for details. * @throws IllegalArgumentException if the classes are not assignable * @since 5.0 */ public static void isAssignable(Class<?> superType, @Nullable Class<?> subType, Supplier<String> messageSupplier) { notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, nullSafeGet(messageSupplier)); } }
/** * Assert that {@code superType.isAssignableFrom(subType)} is {@code true}. * <pre class="code">Assert.isAssignable(Number.class, myClass, "Number expected");</pre> * @param superType the super type to check against * @param subType the sub type to check * @param message a message which will be prepended to provide further context. * If it is empty or ends in ":" or ";" or "," or ".", a full exception message * will be appended. If it ends in a space, the name of the offending sub type * will be appended. In any other case, a ":" with a space and the name of the * offending sub type will be appended. * @throws IllegalArgumentException if the classes are not assignable */ public static void isAssignable(Class<?> superType, @Nullable Class<?> subType, String message) { notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, message); } }
/** * Assert that {@code superType.isAssignableFrom(subType)} is {@code true}. * <pre class="code"> * Assert.isAssignable(Number.class, myClass, () -> "Processing " + myAttributeName + ":"); * </pre> * @param superType the super type to check against * @param subType the sub type to check * @param messageSupplier a supplier for the exception message to use if the * assertion fails. See {@link #isAssignable(Class, Class, String)} for details. * @throws IllegalArgumentException if the classes are not assignable * @since 5.0 */ public static void isAssignable(Class<?> superType, @Nullable Class<?> subType, Supplier<String> messageSupplier) { notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, nullSafeGet(messageSupplier)); } }
/** * Assert that {@code superType.isAssignableFrom(subType)} is {@code true}. * <pre class="code">Assert.isAssignable(Number.class, myClass, "Number expected");</pre> * @param superType the super type to check against * @param subType the sub type to check * @param message a message which will be prepended to provide further context. * If it is empty or ends in ":" or ";" or "," or ".", a full exception message * will be appended. If it ends in a space, the name of the offending sub type * will be appended. In any other case, a ":" with a space and the name of the * offending sub type will be appended. * @throws IllegalArgumentException if the classes are not assignable */ public static void isAssignable(Class<?> superType, @Nullable Class<?> subType, String message) { notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, message); } }
/** * Assert that {@code superType.isAssignableFrom(subType)} is {@code true}. * <pre class="code"> * Assert.isAssignable(Number.class, myClass, () -> "Processing " + myAttributeName + ":"); * </pre> * @param superType the super type to check against * @param subType the sub type to check * @param messageSupplier a supplier for the exception message to use if the * assertion fails. See {@link #isAssignable(Class, Class, String)} for details. * @throws IllegalArgumentException if the classes are not assignable * @since 5.0 */ public static void isAssignable(Class<?> superType, @Nullable Class<?> subType, Supplier<String> messageSupplier) { notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, nullSafeGet(messageSupplier)); } }
notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, message); notNull(superType, "Super type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { assignableCheckFailed(superType, subType, nullSafeGet(messageSupplier));