| 1 16 package nl.hippo.asserts; 17 18 public class ObjectAsserts extends Asserts 19 { 20 21 public static void notNull(Object object, ExceptionFactory exceptionFactory, String identifier) 22 { 23 if (object == null) 24 { 25 throw createException(exceptionFactory, identifier + " cannot be null"); 26 } 27 } 28 29 public static void equal(Object first, Object second, ExceptionFactory exceptionFactory, String firstIdentifier, String secondIdentifier) 30 { 31 boolean result; 32 if (first == null) 33 { 34 result = second == null; 35 } 36 else 37 { 38 result = first.equals(second); 39 } 40 if (!result) 41 { 42 throw createException(exceptionFactory, firstIdentifier + " must be equal to " + secondIdentifier); 43 } 44 } 45 46 51 public static void notNull(Object object, RuntimeException exception) 52 { 53 if (object == null) 54 { 55 throw exception; 56 } 57 } 58 59 private ObjectAsserts() 60 { 61 super(); 62 } 63 64 } | Popular Tags |