/** * Precondition-style validation that throws {@link IllegalArgumentException}. * * @param isValid * {@code true} if valid, {@code false} if an exception should be * thrown * @param message * A String message for the exception. * @param args * Objects used to fill in {@code %s} placeholders in the message * @throws IllegalArgumentException if {@code isValid} is false */ public static void checkArgument(boolean isValid, String message, Object... args) throws IllegalArgumentException { if (!isValid) { throw new IllegalArgumentException( String.format(String.valueOf(message), strings(args))); } }
/** * Precondition-style validation that throws {@link IllegalArgumentException}. * * @param isValid * {@code true} if valid, {@code false} if an exception should be * thrown * @param message * A String message for the exception. * @param args * Objects used to fill in {@code %s} placeholders in the message * @throws IllegalArgumentException if {@code isValid} is false */ public static void checkArgument(boolean isValid, String message, Object... args) throws IllegalArgumentException { if (!isValid) { throw new IllegalArgumentException( String.format(String.valueOf(message), strings(args))); } }
/** * Precondition-style validation that throws {@link IllegalStateException}. * * @param isValid * {@code true} if valid, {@code false} if an exception should be * thrown * @param message * A String message for the exception. * @param args * Objects used to fill in {@code %s} placeholders in the message * @throws IllegalStateException if {@code isValid} is false */ public static void checkState(boolean isValid, String message, Object... args) throws IllegalStateException { if (!isValid) { throw new IllegalStateException( String.format(String.valueOf(message), strings(args))); } }
/** * Precondition-style validation that throws {@link IllegalStateException}. * * @param isValid * {@code true} if valid, {@code false} if an exception should be * thrown * @param message * A String message for the exception. * @param args * Objects used to fill in {@code %s} placeholders in the message * @throws IllegalStateException if {@code isValid} is false */ public static void checkState(boolean isValid, String message, Object... args) throws IllegalStateException { if (!isValid) { throw new IllegalStateException( String.format(String.valueOf(message), strings(args))); } }