1 package de.java2html.util; 2 3 6 public class Ensure { 7 8 public Ensure() { 9 super(); 10 } 11 12 public static void ensureArgumentNotNull(String message, Object object) throws IllegalArgumentException { 13 ensureTrue(message, object != null); 14 } 15 16 public static void ensureArgumentNotNull(Object object) throws IllegalArgumentException { 17 ensureArgumentNotNull("Object must not be null", object); } 19 20 public static void ensureArgumentFalse(boolean state) throws IllegalArgumentException { 21 ensureTrue("boolean must be false", !state); } 23 24 public static void ensureArgumentFalse(String message, boolean state) throws IllegalArgumentException { 25 ensureTrue(message, !state); 26 } 27 28 public static void ensureArgumentTrue(boolean state) throws IllegalArgumentException { 29 ensureTrue("boolean must be true", state); } 31 32 public static void ensureTrue(String message, boolean state) throws IllegalArgumentException { 33 if (!state){ 34 throw new IllegalArgumentException (message); 35 } 36 } 37 } | Popular Tags |