-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacek Kwiecień
committed
Jun 16, 2016
1 parent
02eb88e
commit 2fe0ec5
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
switcher-library/src/main/java/pl/aprilapps/switcher/guava/Preconditions.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package pl.aprilapps.switcher.guava; | ||
|
||
/** | ||
* Created by Jacek Kwiecień on 08.06.16. | ||
*/ | ||
public final class Preconditions { | ||
|
||
private Preconditions() { | ||
} | ||
|
||
|
||
/** | ||
* 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 {@code reference} is null | ||
*/ | ||
public static <T> T checkNotNull(T reference, Object errorMessage) { | ||
if (reference == null) { | ||
throw new NullPointerException(String.valueOf(errorMessage)); | ||
} | ||
return reference; | ||
} | ||
|
||
} |