@Test public void testPreconditions(){ Preconditions.checkArgument(true); try{ Preconditions.checkArgument(false); } catch (IllegalArgumentException e){ assertNull(e.getMessage()); } Preconditions.checkArgument(true, "Message %s here", 10); try{ Preconditions.checkArgument(false, "Message %s here", 10); } catch (IllegalArgumentException e){ assertEquals("Message 10 here", e.getMessage()); } Preconditions.checkArgument(true, "Message %s here %s there", 10, 20); try{ Preconditions.checkArgument(false, "Message %s here %s there", 10, 20); } catch (IllegalArgumentException e){ assertEquals("Message 10 here 20 there", e.getMessage()); } Preconditions.checkArgument(true, "Message %s here %s there %s more", 10, 20, 30); try{ Preconditions.checkArgument(false, "Message %s here %s there %s more", 10, 20, 30); } catch (IllegalArgumentException e){ assertEquals("Message 10 here 20 there 30 more", e.getMessage()); } Preconditions.checkArgument(true, "Message %s here", 10L); try{ Preconditions.checkArgument(false, "Message %s here", 10L); } catch (IllegalArgumentException e){ assertEquals("Message 10 here", e.getMessage()); } Preconditions.checkArgument(true, "Message %s here %s there", 10L, 20L); try{ Preconditions.checkArgument(false, "Message %s here %s there", 10L, 20L); } catch (IllegalArgumentException e){ assertEquals("Message 10 here 20 there", e.getMessage()); } Preconditions.checkArgument(true, "Message %s here %s there %s more", 10L, 20L, 30L); try{ Preconditions.checkArgument(false, "Message %s here %s there %s more", 10L, 20L, 30L); } catch (IllegalArgumentException e){ assertEquals("Message 10 here 20 there 30 more", e.getMessage()); } Preconditions.checkArgument(true, "Message %s here %s there %s more", "A", "B", "C"); try{ Preconditions.checkArgument(false, "Message %s here %s there %s more", "A", "B", "C"); } catch (IllegalArgumentException e){ assertEquals("Message A here B there C more", e.getMessage()); } }
private Preconditions() { }
Preconditions { private Preconditions() { } }
Preconditions { private Preconditions() { } private  Preconditions(); }
Preconditions { private Preconditions() { } 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 { private Preconditions() { } 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);  }