Ensures that an object reference passed as a parameter to the calling method is not null. @param reference an object reference @return the non-null reference that was validated @throws NullPointerException if reference is null
(T reference)
| 29 | * @throws NullPointerException if {@code reference} is null |
| 30 | */ |
| 31 | public static <T> T checkNotNull(T reference) { |
| 32 | if (reference == null) { |
| 33 | throw new NullPointerException(); |
| 34 | } |
| 35 | return reference; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Ensures that an object reference passed as a parameter to the calling method is not null. |