1 19 20 package org.netbeans.modules.debugger.jpda.expr; 21 22 import java.util.Collection ; 23 24 29 class Assert { 30 31 static Object error(SimpleNode node, String param) throws EvaluationException { 32 return error(node, param, null); 33 } 34 35 static Object error(SimpleNode node, String cause, Object p2) throws EvaluationException { 36 return error(node, cause, new Object [] { p2 }); 37 } 38 39 static Object error(SimpleNode node, String cause, Object p2, Object p3) throws EvaluationException { 40 return error(node, cause, new Object [] { p2, p3}); 41 } 42 43 static Object error(SimpleNode node, String cause, Object p1, Object p2, Object p3) throws EvaluationException { 44 return error(node, cause, new Object [] { p1, p2, p3}); 45 } 46 47 private static Object error (SimpleNode node, String cause, Object [] params) throws EvaluationException { 48 throw new EvaluationException(node, cause, params); 49 } 50 51 static void assertAssignable(Object o, Class aClass, SimpleNode s, String p1, Object p2) { 52 if (o != null && !aClass.isAssignableFrom(o.getClass())) { 53 error(s, p1, p2); 54 } 55 } 56 57 static void assertAssignable(Object o, Class aClass, SimpleNode s, String p1, Object p2, Object p3) { 58 if (o != null && !aClass.isAssignableFrom(o.getClass())) { 59 error(s, p1, p2, p3); 60 } 61 } 62 63 static void assertNotAssignable(Object o, Class aClass, SimpleNode s, String p1, Object p2) { 64 if (aClass.isAssignableFrom(o.getClass())) { 65 error(s, p1, p2); 66 } 67 } 68 69 static void assertNotAssignable(Object o, Class aClass, SimpleNode s, String p1, Object p2, Object p3) { 70 if (aClass.isAssignableFrom(o.getClass())) { 71 error(s, p1, p2, p3); 72 } 73 } 74 75 static void assertNotAssignable(Object o, Class aClass, SimpleNode node, String s) { 76 if (aClass.isAssignableFrom(o.getClass())) { 77 error(node, s); 78 } 79 } 80 81 static void assertLess(int a, int b, SimpleNode s, String p1, Object p2, Object p3) { 82 if (a >= b) { 83 error(s, p1, p2, p3); 84 } 85 } 86 87 static void assertNotNull(Object obj, SimpleNode s, String identifier) { 88 if (obj == null) { 89 error(s, identifier); 90 } 91 } 92 93 static void assertNonEmpty(Collection collection, SimpleNode s, String p1, Object p2) { 94 if (collection == null || collection.size() == 0) { 95 error(s, p1, p2); 96 } 97 } 98 99 static void assertNotNull(Object obj, SimpleNode node, String p1, Object p2) { 100 if (obj == null) { 101 error(node, p1, p2); 102 } 103 } 104 105 } 106 | Popular Tags |