Spring Source of-assert.notnull

Source: Internet
Author: User

Org.springframework.util.AssertAssert translated to Chinese as "assertion". You should know this concept by using JUnit. It is to determine that an actual value is what you expect, and if not, throw an exception. Assert is often used to: 1. Determine whether the parameter of the method is of normal value. Used in 2.JUNIT. I found a bug in SPRING1.2.6, please see:
in Org.springframework.core.io.support.EncodedResource  Public Encodedresource (Resource Resource, String encoding) {  assert.notnull ("Resource is required");   this. Resource = resource;   this. Encoding = encoding;}

Assert.notnull ("Resource is required");
This sentence should be for
Assert.notnull (Resource, "resource is required");
Otherwise resource didn't pass over, also broken what say Ah, hehe. ------------------------------------------------------------------------above is seen on the internet, but I entered spring inside to look at the source code, as follows:
/*** Assert that a object is not <code>null</code>. * <pre class= "code" >assert.notnull (Clazz, "the CLA SS must not is null "); </pre>*@paramobject The object to check*@parammessage The exception message to use if the assertion fails*@throwsIllegalArgumentException If the object is <code>null</code>*/ Public Static voidNotnull (Object object, String message) {if(Object = =NULL) {Throw Newillegalargumentexception (message); }}
The function means that the incoming object must not be empty. Throws an exception if it is empty. Transferred from: http://jack-chen10.blog.163.com/blog/static/6775128201348545984/

Spring Source of-assert.notnull

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.