Top Description Constructors Methods
org.hamcrest.core

public Class IsNull<T>

extends BaseMatcher<T>
Class Inheritance
Static Imports
org.hamcrest.core.IsNot.not

Is the value null?

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
describeTo(Description
The description to be built or appended to.
description
)

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
public boolean
matches(Object
the object against which the matcher is evaluated.
o
)

Implements org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item.
public static Matcher<Object>
notNullValue()

A shortcut to the frequently used not(nullValue()).

public static <T> Matcher<T>
notNullValue(Class<T>
dummy parameter used to infer the generic type of the returned matcher
type
)

A shortcut to the frequently used not(nullValue(X.class)).

public static Matcher<Object>
nullValue()

Creates a matcher that matches if examined object is null.

public static <T> Matcher<T>
nullValue(Class<T>
dummy parameter used to infer the generic type of the returned matcher
type
)

Creates a matcher that matches if examined object is null.

Inherited from org.hamcrest.BaseMatcher:
_dont_implement_Matcher___instead_extend_BaseMatcher_describeMismatchtoString

Constructor Detail

IsNullback to summary
public IsNull()

Method Detail

describeToback to summary
public void describeTo(Description description)

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
matchesback to summary
public boolean matches(Object o)

Implements org.hamcrest.Matcher.matches.

Doc from org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item.

This method matches against Object, instead of the generic type T. This is because the caller of the Matcher does not know at runtime what the type is (because of type erasure with Java generics). It is down to the implementations to check the correct type.

Parameters
o:Object

the object against which the matcher is evaluated.

Returns:boolean

true if item matches, otherwise false.

Annotations
@Override
notNullValueback to summary
public static Matcher<Object> notNullValue()

A shortcut to the frequently used not(nullValue()).

For example:

assertThat(cheese, is(notNullValue()))
instead of:
assertThat(cheese, is(not(nullValue())))
Annotations
@Factory
notNullValueback to summary
public static <T> Matcher<T> notNullValue(Class<T> type)

A shortcut to the frequently used not(nullValue(X.class)). Accepts a single dummy argument to facilitate type inference..

For example:

assertThat(cheese, is(notNullValue(X.class)))
instead of:
assertThat(cheese, is(not(nullValue(X.class))))
Parameters
type:Class<T>

dummy parameter used to infer the generic type of the returned matcher

Annotations
@Factory
nullValueback to summary
public static Matcher<Object> nullValue()

Creates a matcher that matches if examined object is null.

For example:

assertThat(cheese, is(nullValue())
Annotations
@Factory
nullValueback to summary
public static <T> Matcher<T> nullValue(Class<T> type)

Creates a matcher that matches if examined object is null. Accepts a single dummy argument to facilitate type inference.

For example:

assertThat(cheese, is(nullValue(Cheese.class))
Parameters
type:Class<T>

dummy parameter used to infer the generic type of the returned matcher

Annotations
@Factory