Package org.neo4j.cypherdsl.core.utils
Class Assertions
- java.lang.Object
-
- org.neo4j.cypherdsl.core.utils.Assertions
-
@API(status=INTERNAL, since="2020.0.0") public final class Assertions extends java.lang.ObjectAssertions used throughout the Cypher-DSL. Mostly copied over from org.springframework.util.Assert. Thanks to the original authors: Keith Donald, Juergen Hoeller, Sam Brannen, Colin Sampaleanu and Rob Harrop. Not supported for external use in anyway.- Since:
- 2020.0.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidhasText(java.lang.String text, java.lang.String message)Assert that the given String contains valid text content; that is, it must not benulland must contain at least one non-whitespace character.static voidisInstanceOf(java.lang.Class<?> type, java.lang.Object obj, java.lang.String message)Assert that the provided object is an instance of the provided class.static voidisTrue(boolean expression, java.lang.String message)Assert a boolean expression, throwing anIllegalArgumentExceptionif the expression evaluates tofalse.static voidnotEmpty(java.lang.Object[] array, java.lang.String message)Assert that an array contains elements; that is, it must not benulland must contain at least one element.static voidnotNull(java.lang.Object object, java.lang.String message)Assert that an object is notnull.
-
-
-
Method Detail
-
hasText
public static void hasText(java.lang.String text, java.lang.String message)Assert that the given String contains valid text content; that is, it must not benulland must contain at least one non-whitespace character.Assert.hasText(name, "'name' must not be empty");
- Parameters:
text- the String to checkmessage- the exception message to use if the assertion fails- Throws:
java.lang.IllegalArgumentException- if the text does not contain valid text content
-
isTrue
public static void isTrue(boolean expression, java.lang.String message)Assert a boolean expression, throwing anIllegalArgumentExceptionif the expression evaluates tofalse.Assert.isTrue(i > 0, "The value must be greater than zero");
- Parameters:
expression- a boolean expressionmessage- the exception message to use if the assertion fails- Throws:
java.lang.IllegalArgumentException- ifexpressionisfalse
-
notNull
public static void notNull(java.lang.Object object, java.lang.String message)Assert that an object is notnull.Assert.notNull(clazz, "The class must not be null");
- Parameters:
object- the object to checkmessage- the exception message to use if the assertion fails- Throws:
java.lang.IllegalArgumentException- if the object isnull
-
isInstanceOf
public static void isInstanceOf(java.lang.Class<?> type, java.lang.Object obj, java.lang.String message)Assert that the provided object is an instance of the provided class.Assert.instanceOf(Foo.class, foo, "Foo expected");
- Parameters:
type- the type to check againstobj- the object to checkmessage- the exception message to use if the assertion fails- Throws:
java.lang.IllegalArgumentException- if the object is not an instance of type
-
notEmpty
public static void notEmpty(java.lang.Object[] array, java.lang.String message)Assert that an array contains elements; that is, it must not benulland must contain at least one element.Assert.notEmpty(array, "The array must contain elements");
- Parameters:
array- the array to checkmessage- the exception message to use if the assertion fails- Throws:
java.lang.IllegalArgumentException- if the object array isnullor contains no elements
-
-