Created
August 14, 2012 04:55
-
-
Save nathanchen/3346383 to your computer and use it in GitHub Desktop.
JAVA - 不能为null值
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static <T> T checkNotNull(T reference) | |
| { | |
| if(reference == null) | |
| throw new NullPointerException(); | |
| return reference; | |
| } | |
| public static <T> T checkNotNull(T reference, @Nullable Object errorMessage) | |
| { | |
| if(reference == null) | |
| throw new NullPointerException(String.valueOf(errorMessage)); | |
| return reference; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment