open static fun isInstanceOf(type: Class<*>, @Nullable obj: Any, message: String): Unit
Assert that the provided object is an instance of the provided class.
Assert.instanceOf(Foo.class, foo, "Foo expected");
type
- the type to check against
message
- a message which will be prepended to provide further context. If it is empty or ends in ":" or ";" or "," or ".", a full exception message will be appended. If it ends in a space, the name of the offending object's type will be appended. In any other case, a ":" with a space and the name of the offending object's type will be appended.
IllegalArgumentException
- if the object is not an instance of type
open static fun isInstanceOf(type: Class<*>, @Nullable obj: Any, messageSupplier: Supplier<String>): Unit
Assert that the provided object is an instance of the provided class.
Assert.instanceOf(Foo.class, foo, () -> "Processing " + Foo.class.getSimpleName() + ":");
type
- the type to check against
messageSupplier
- a supplier for the exception message to use if the assertion fails. See #isInstanceOf(Class, Object, String)
for details.
IllegalArgumentException
- if the object is not an instance of type
Since
5.0
open static fun isInstanceOf(type: Class<*>, @Nullable obj: Any): Unit
Assert that the provided object is an instance of the provided class.
Assert.instanceOf(Foo.class, foo);
type
- the type to check against
IllegalArgumentException
- if the object is not an instance of type