diff options
author | Paul Duffin <paulduffin@google.com> | 2017-01-24 13:38:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-01-24 13:38:36 +0000 |
commit | b5937e4be30f2e59c4867278554bacb92c8e10a4 (patch) | |
tree | aa4a6a53609f47d386dfa114be0abfc01e0e5dff /hamcrest-core/src/main/java/org/hamcrest/core/IsNull.java | |
parent | 013fc08d6fe3bfc14b1599e77636e6d57a9568b7 (diff) | |
parent | 5d9cc8c989815b4180a6a0bd220dbfd35e126c84 (diff) | |
download | hamcrest-b5937e4be30f2e59c4867278554bacb92c8e10a4.tar.gz |
Merge "Match upstream file structure"
am: 5d9cc8c989
Change-Id: I3b544565dfe8750cda1b1b10c2231dda02f54470
Diffstat (limited to 'hamcrest-core/src/main/java/org/hamcrest/core/IsNull.java')
-rw-r--r-- | hamcrest-core/src/main/java/org/hamcrest/core/IsNull.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/hamcrest-core/src/main/java/org/hamcrest/core/IsNull.java b/hamcrest-core/src/main/java/org/hamcrest/core/IsNull.java new file mode 100644 index 0000000..737dcf2 --- /dev/null +++ b/hamcrest-core/src/main/java/org/hamcrest/core/IsNull.java @@ -0,0 +1,55 @@ +/* Copyright (c) 2000-2006 hamcrest.org + */ +package org.hamcrest.core; + +import static org.hamcrest.core.IsNot.not; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.Factory; +import org.hamcrest.BaseMatcher; + +/** + * Is the value null? + */ +public class IsNull<T> extends BaseMatcher<T> { + public boolean matches(Object o) { + return o == null; + } + + public void describeTo(Description description) { + description.appendText("null"); + } + + /** + * Matches if value is null. + */ + @Factory + public static <T> Matcher<T> nullValue() { + return new IsNull<T>(); + } + + /** + * Matches if value is not null. + */ + @Factory + public static <T> Matcher<T> notNullValue() { + return not(IsNull.<T>nullValue()); + } + + /** + * Matches if value is null. With type inference. + */ + @Factory + public static <T> Matcher<T> nullValue(@SuppressWarnings("unused") Class<T> type) { + return nullValue(); + } + + /** + * Matches if value is not null. With type inference. + */ + @Factory + public static <T> Matcher<T> notNullValue(@SuppressWarnings("unused") Class<T> type) { + return notNullValue(); + } +} + |