@Test public void testPreconditionsMalformedState(){ Preconditions.checkState(true, "This is malformed", "A", "B", "C"); try{ Preconditions.checkState(false, "This is malformed", "A", "B", "C"); } catch (IllegalStateException e){ assertEquals("This is malformed [A,B,C]", e.getMessage()); } Preconditions.checkState(true, "This is %s malformed", "A", "B", "C"); try{ Preconditions.checkState(false, "This is %s malformed", "A", "B", "C"); } catch (IllegalStateException e){ assertEquals("This is A malformed [B,C]", e.getMessage()); } Preconditions.checkState(true, "This is %s %s malformed"); try{ Preconditions.checkState(false, "This is %s %s malformed"); } catch (IllegalStateException e){ assertEquals("This is %s %s malformed", e.getMessage()); } Preconditions.checkState(true, "This is %s %s malformed", "A"); try{ Preconditions.checkState(false, "This is %s %s malformed", "A"); } catch (IllegalStateException e){ assertEquals("This is A %s malformed", e.getMessage()); } }
public static void checkState(boolean b) { if (!b) { throw new IllegalStateException(); } }
Preconditions { public static void checkState(boolean b) { if (!b) { throw new IllegalStateException(); } } }
Preconditions { public static void checkState(boolean b) { if (!b) { throw new IllegalStateException(); } } private  Preconditions(); }
Preconditions { public static void checkState(boolean b) { if (!b) { throw new IllegalStateException(); } } private  Preconditions(); static void checkArgument(boolean b); static void checkArgument(boolean b, String message); static void checkArgument(boolean b, String msg, int arg1); static void checkArgument(boolean b, String msg, long arg1); static void checkArgument(boolean b, String msg, double arg1); static void checkArgument(boolean b, String msg, Object arg1); static void checkArgument(boolean b, String msg, int arg1, int arg2); static void checkArgument(boolean b, String msg, long arg1, long arg2); static void checkArgument(boolean b, String msg, double arg1, double arg2); static void checkArgument(boolean b, String msg, Object arg1, Object arg2); static void checkArgument(boolean b, String msg, int arg1, int arg2, int arg3); static void checkArgument(boolean b, String msg, long arg1, long arg2, long arg3); static void checkArgument(boolean b, String msg, double arg1, double arg2, double arg3); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3); static void checkArgument(boolean b, String msg, int arg1, int arg2, int arg3, int arg4); static void checkArgument(boolean b, String msg, long arg1, long arg2, long arg3, long arg4); static void checkArgument(boolean b, String msg, double arg1, double arg2, double arg3, double arg4); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6); static void checkArgument(boolean b, String message, Object... args); static void checkState(boolean b); static void checkState(boolean b, String message); static void checkState(boolean b, String msg, int arg1); static void checkState(boolean b, String msg, long arg1); static void checkState(boolean b, String msg, double arg1); static void checkState(boolean b, String msg, Object arg1); static void checkState(boolean b, String msg, int arg1, int arg2); static void checkState(boolean b, String msg, long arg1, long arg2); static void checkState(boolean b, String msg, double arg1, double arg2); static void checkState(boolean b, String msg, Object arg1, Object arg2); static void checkState(boolean b, String msg, int arg1, int arg2, int arg3); static void checkState(boolean b, String msg, long arg1, long arg2, long arg3); static void checkState(boolean b, String msg, double arg1, double arg2, double arg3); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3); static void checkState(boolean b, String msg, int arg1, int arg2, int arg3, int arg4); static void checkState(boolean b, String msg, long arg1, long arg2, long arg3, long arg4); static void checkState(boolean b, String msg, double arg1, double arg2, double arg3, double arg4); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6); static void checkState(boolean b, String message, Object... args); static void checkNotNull(Object o); static void checkNotNull(Object o, String message); static void checkNotNull(Object o, String msg, int arg1); static void checkNotNull(Object o, String msg, long arg1); static void checkNotNull(Object o, String msg, double arg1); static void checkNotNull(Object o, String msg, Object arg1); static void checkNotNull(Object o, String msg, int arg1, int arg2); static void checkNotNull(Object o, String msg, long arg1, long arg2); static void checkNotNull(Object o, String msg, double arg1, double arg2); static void checkNotNull(Object o, String msg, Object arg1, Object arg2); static void checkNotNull(Object o, String msg, int arg1, int arg2, int arg3); static void checkNotNull(Object o, String msg, long arg1, long arg2, long arg3); static void checkNotNull(Object o, String msg, double arg1, double arg2, double arg3); static void checkNotNull(Object o, String msg, Object arg1, Object arg2, Object arg3); static void checkNotNull(Object o, String msg, int arg1, int arg2, int arg3, int arg4); static void checkNotNull(Object o, String msg, long arg1, long arg2, long arg3, long arg4); static void checkNotNull(Object o, String msg, double arg1, double arg2, double arg3, double arg4); static void checkNotNull(Object o, String msg, Object arg1, Object arg2, Object arg3, Object arg4); static void checkNotNull(Object o, String message, Object... args); static void throwEx(String message, Object... args); static void throwStateEx(String message, Object... args); static void throwNullPointerEx(String message, Object... args); static String formatArray(Object o); }
Preconditions { public static void checkState(boolean b) { if (!b) { throw new IllegalStateException(); } } private  Preconditions(); static void checkArgument(boolean b); static void checkArgument(boolean b, String message); static void checkArgument(boolean b, String msg, int arg1); static void checkArgument(boolean b, String msg, long arg1); static void checkArgument(boolean b, String msg, double arg1); static void checkArgument(boolean b, String msg, Object arg1); static void checkArgument(boolean b, String msg, int arg1, int arg2); static void checkArgument(boolean b, String msg, long arg1, long arg2); static void checkArgument(boolean b, String msg, double arg1, double arg2); static void checkArgument(boolean b, String msg, Object arg1, Object arg2); static void checkArgument(boolean b, String msg, int arg1, int arg2, int arg3); static void checkArgument(boolean b, String msg, long arg1, long arg2, long arg3); static void checkArgument(boolean b, String msg, double arg1, double arg2, double arg3); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3); static void checkArgument(boolean b, String msg, int arg1, int arg2, int arg3, int arg4); static void checkArgument(boolean b, String msg, long arg1, long arg2, long arg3, long arg4); static void checkArgument(boolean b, String msg, double arg1, double arg2, double arg3, double arg4); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5); static void checkArgument(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6); static void checkArgument(boolean b, String message, Object... args); static void checkState(boolean b); static void checkState(boolean b, String message); static void checkState(boolean b, String msg, int arg1); static void checkState(boolean b, String msg, long arg1); static void checkState(boolean b, String msg, double arg1); static void checkState(boolean b, String msg, Object arg1); static void checkState(boolean b, String msg, int arg1, int arg2); static void checkState(boolean b, String msg, long arg1, long arg2); static void checkState(boolean b, String msg, double arg1, double arg2); static void checkState(boolean b, String msg, Object arg1, Object arg2); static void checkState(boolean b, String msg, int arg1, int arg2, int arg3); static void checkState(boolean b, String msg, long arg1, long arg2, long arg3); static void checkState(boolean b, String msg, double arg1, double arg2, double arg3); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3); static void checkState(boolean b, String msg, int arg1, int arg2, int arg3, int arg4); static void checkState(boolean b, String msg, long arg1, long arg2, long arg3, long arg4); static void checkState(boolean b, String msg, double arg1, double arg2, double arg3, double arg4); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5); static void checkState(boolean b, String msg, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6); static void checkState(boolean b, String message, Object... args); static void checkNotNull(Object o); static void checkNotNull(Object o, String message); static void checkNotNull(Object o, String msg, int arg1); static void checkNotNull(Object o, String msg, long arg1); static void checkNotNull(Object o, String msg, double arg1); static void checkNotNull(Object o, String msg, Object arg1); static void checkNotNull(Object o, String msg, int arg1, int arg2); static void checkNotNull(Object o, String msg, long arg1, long arg2); static void checkNotNull(Object o, String msg, double arg1, double arg2); static void checkNotNull(Object o, String msg, Object arg1, Object arg2); static void checkNotNull(Object o, String msg, int arg1, int arg2, int arg3); static void checkNotNull(Object o, String msg, long arg1, long arg2, long arg3); static void checkNotNull(Object o, String msg, double arg1, double arg2, double arg3); static void checkNotNull(Object o, String msg, Object arg1, Object arg2, Object arg3); static void checkNotNull(Object o, String msg, int arg1, int arg2, int arg3, int arg4); static void checkNotNull(Object o, String msg, long arg1, long arg2, long arg3, long arg4); static void checkNotNull(Object o, String msg, double arg1, double arg2, double arg3, double arg4); static void checkNotNull(Object o, String msg, Object arg1, Object arg2, Object arg3, Object arg4); static void checkNotNull(Object o, String message, Object... args); static void throwEx(String message, Object... args); static void throwStateEx(String message, Object... args); static void throwNullPointerEx(String message, Object... args); static String formatArray(Object o);  }