Java Utililty Methods Assert

List of utility methods to do Assert

Description

The list of methods to do Assert are organized into topic(s).

Method

voidassertValidKeys(Iterable keys)
assert Valid Keys
if (keys == null)
    throw new IllegalArgumentException("Keys cannot be null.");
for (Object key : keys)
    assertValidKey(key);
voidassertValidRange(String name, double value, double min, double max)
assert Valid Range
if (min <= value && value <= max)
    return;
throw new IllegalArgumentException("invalid " + name + ": " + value + " not in [" + min + "," + max + "]");
StringassertValidSwfValue(String value)
Assert the value passes the constraints for SWF fields like name, version, domain, taskList, identifiers.
if (value != null) {
    if (value.length() == 0) {
        throw new AssertionError("Empty value not allowed");
    if (value.matches("\\s.*|.*\\s") || value.matches(".*[:/|\\u0000-\\u001f\\u007f-\\u009f].*")
            || value.contains("arn")) {
        throw new AssertionError("Value contains one or more bad characters: '" + value + "'");
return value;
voidassertValueSize(final int expectedSize, final int got)
assert Value Size
if (got != expectedSize) {
    throw new AssertionError("Expected " + expectedSize + " but got " + got);
voidassertXYPlanesCorrectlyOriented(final int[] dimIndices)
Throws an Exception if the planes of a Dataset are not compatible with legacy ImageJ.
if (dimIndices[0] != 0) {
    throw new IllegalArgumentException("Dataset does not have X as the first axis");
if (dimIndices[1] != 1) {
    throw new IllegalArgumentException("Dataset does not have Y as the second axis");