These days more busy looking at the previous project, found this spring under the Assert method, (previously used, but it seems to forget almost the * *)
Org.springframework.util.Assert;
The Assert assertion tool class, typically used for data legitimacy checks.
It's usually written like this in the usual judgment.
if (message== null | | message.equls ("")) {
throw new IllegalArgumentException ("Incorrect input information!");
}
The code above with the Assert tool class can be simplified to:
Assert.hastext (Message, "Input information Error!");
Here's a look at the common assertion methods in the Assert class that I collected:
Assert.notnull (Object object, "object is required")-Object non-empty
Assert.istrue (Object object, "object must be True")-the object must be True
Assert.notempty (Collection Collection, "Collection must not being empty")-collection non-empty
Assert.haslength (String text, "text must be specified")-the character is not null and the character length is not 0
Assert.hastext (String text, "text must not is empty")-text is not null and must contain at least one character that is not a space
Assert.isinstanceof (class Clazz, Object obj, "clazz must be of type [Clazz]")-obj must be able to be properly styled as a clazz-specified class
The basic use of spring's assertion tool class assert