private static String badPositionIndex(int index, int size, String desc) { if (index < 0) { return format("%s (%s) must not be negative", desc, index); } else if (size < 0) { throw new IllegalArgumentException("negative size: " + size); } else { // index > size return format("%s (%s) must not be greater than size (%s)", desc, index, size); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState(boolean b, @Nullable String errorMessageTemplate, long p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } }
/** * Ensures that an object reference passed as a parameter to the calling method is not null. * <p/> * <p>See {@link #checkNotNull(Object, String, Object...)} for details. */ public static <T> T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1)); } return obj; }
/** * Ensures the truth of an expression involving one or more parameters to the calling method. * <p/> * <p>See {@link #checkArgument(boolean, String, Object...)} for details. */ public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, int p1, char p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState(boolean b, @Nullable String errorMessageTemplate, long p1, int p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures that an object reference passed as a parameter to the calling method is not null. * <p/> * <p>See {@link #checkNotNull(Object, String, Object...)} for details. */ public static <T> T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, long p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } return obj; }
/** * Ensures that an object reference passed as a parameter to the calling method is not null. * <p/> * <p>See {@link #checkNotNull(Object, String, Object...)} for details. */ public static <T> T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, char p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } return obj; }
/** * Ensures the truth of an expression involving one or more parameters to the calling method. * <p/> * <p>See {@link #checkArgument(boolean, String, Object...)} for details. */ public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures that an object reference passed as a parameter to the calling method is not null. * <p/> * <p>See {@link #checkNotNull(Object, String, Object...)} for details. */ public static <T> T checkNotNull( T obj, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } return obj; }
/** * Ensures the truth of an expression involving one or more parameters to the calling method. * <p/> * <p>See {@link #checkArgument(boolean, String, Object...)} for details. */ public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures the truth of an expression involving one or more parameters to the calling method. * <p/> * <p>See {@link #checkArgument(boolean, String, Object...)} for details. */ public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState( boolean b, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures that an object reference passed as a parameter to the calling method is not null. * <p/> * <p>See {@link #checkNotNull(Object, String, Object...)} for details. */ public static <T> T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1)); } return obj; }
/** * Ensures that an object reference passed as a parameter to the calling method is not null. * <p/> * <p>See {@link #checkNotNull(Object, String, Object...)} for details. */ public static <T> T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } return obj; }
/** * Ensures the truth of an expression involving one or more parameters to the calling method. * <p/> * <p>See {@link #checkArgument(boolean, String, Object...)} for details. */ public static void checkArgument( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } }
/** * Ensures the truth of an expression involving the state of the calling instance, but not * involving any parameters to the calling method. * <p/> * <p>See {@link #checkState(boolean, String, Object...)} for details. */ public static void checkState( boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } }