The list of methods to do Assert are organized into topic(s).
void
assertArrayType(Object array) Assert the object is array or not
Class<?> type = array.getClass();
if (!type.isArray()) {
String message = String.format("The argument is not an array object, its type is %s", type.getName());
throw new IllegalArgumentException(message);
void
assertAssertionsEnabled() assert Assertions Enabled
boolean assertOn = false;
assert assertOn = true;
if (!assertOn) {
throw new RuntimeException("Asserts not enabled; enable assertions using the '-ea' JVM option");
void
assertAttributeNameIsLegal(final String attributeName) Check whether the given String represents a legal attribute name according to the SAM spec, and throw an exception if it doesn't.
if (attributeName == null || attributeName.length() != 2 || !Character.isLetter(attributeName.charAt(0))
|| !Character.isLetterOrDigit(attributeName.charAt(1))) {
throw new IllegalArgumentException("Read attribute " + attributeName
+ " invalid: attribute names must be non-null two-character Strings matching the pattern /[A-Za-z][A-Za-z0-9]/");
void
assertBounds(final long reqOff, final long reqLen, final long allocSize) Perform bounds checking using java assert (if enabled) checking the requested offset and length against the allocated size.
assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) : "offset: " + reqOff
+ ", reqLength: " + reqLen + ", size: " + allocSize;
String
assertCharactersNotInString(final String illegalChars, final char... chars) Checks that a String doesn't contain one or more characters of interest.
for (final char illegalChar : illegalChars.toCharArray()) {
for (final char ch : chars) {
if (illegalChar == ch) {
throw new IllegalArgumentException(
"Supplied String contains illegal character '" + illegalChar + "'.");
return illegalChars;