Skip to content

Commit

Permalink
Add model for Preconditions.checkNotNull(obj, message). (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaroclapp committed Feb 27, 2019
1 parent b3f887e commit 3a1e2bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -195,6 +195,10 @@ private static class DefaultLibraryModels implements LibraryModels {
private static final ImmutableSetMultimap<MethodRef, Integer> FAIL_IF_NULL_PARAMETERS =
new ImmutableSetMultimap.Builder<MethodRef, Integer>()
.put(methodRef("com.google.common.base.Preconditions", "<T>checkNotNull(T)"), 0)
.put(
methodRef(
"com.google.common.base.Preconditions", "<T>checkNotNull(T,java.lang.Object)"),
0)
.put(methodRef("java.util.Objects", "<T>requireNonNull(T)"), 0)
.put(methodRef("java.util.Objects", "<T>requireNonNull(T,java.lang.String)"), 0)
.put(methodRef("org.junit.Assert", "assertNotNull(java.lang.Object)"), 0)
Expand Down
Expand Up @@ -524,6 +524,11 @@ static void checkNotNull(@Nullable Object o) {
o.toString();
}

static void checkNotNullWithMessage(@Nullable Object o) {
Preconditions.checkNotNull(o, "should not be null");
o.toString();
}

static void requireNonNull(@Nullable Object o, @Nullable Object p) {
Objects.requireNonNull(o);
o.toString();
Expand Down

0 comments on commit 3a1e2bf

Please sign in to comment.