List of utility methods to do Assert
void | assertIOThread(Thread t, boolean flag) assert IO Thread if (flag) { assert t.equals(Thread.currentThread()) : "Management NOT on IO thread when expected"; } else { assert !(t.equals(Thread.currentThread())) : "Management on IO thread when not expected"; |
void | assertIsClass(Class extends Object> klazz) assert Is Class assertionIllegalArgument(isClass(klazz), "Type " + klazz + " must not be an interface."); |
void | assertIsNotEmptyString(String string) assert Is Not Empty String if (string.isEmpty()) { throw new IllegalArgumentException("string can't be empty."); |
void | assertIsPermutation(int[] perm) assert Is Permutation boolean hit[] = new boolean[perm.length]; for (int i : perm) { assert !hit[i]; hit[i] = true; |
int | assertIsPositive(int num, String fieldName) Asserts that the given number is positive (non-negative and non-zero). if (num <= 0) { throw new IllegalArgumentException(String.format("%s must be positive", fieldName)); return num; |
void | assertIsProb(double x) assert Is Prob assert isProb(x) : "Not a probability [0, 1]: " + x; |
void | assertIsProbability(final double probability) Checks to make sure that probability is between 0.0 and 1.0. if (probability < 0.0 || probability > 1.0) { throw new IllegalArgumentException("Probability (" + probability + ") must be in [0.0, 1.0]"); |
void | assertIsProperlyQuoted(String header, String tag) assert Is Properly Quoted if (tag.length() < 2 || !tag.startsWith(QUOTATION_MARK) || !tag.endsWith(QUOTATION_MARK)) { throw new IllegalArgumentException(MISFORMATTED_ENTITY_TAG + header); |
void | assertIsReady() assert Is Ready if (!ready) { throw new IllegalStateException("System is not ready for remote calls. " + "When beans are making remote calls in initialization, it's better to " + "implement io.servicecomb.core.BootListener and do it after EventType.AFTER_REGISTRY."); |
void | assertLegal(Object underAssertion, String message) assert Legal assertionIllegalArgument(underAssertion != null, message); |