All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ext.test4j.hamcrest.core.IsNull Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
/*  Copyright (c) 2000-2010 hamcrest.org
 */
package ext.test4j.hamcrest.core;

import static ext.test4j.hamcrest.core.IsNot.not;
import ext.test4j.hamcrest.BaseMatcher;
import ext.test4j.hamcrest.Description;
import ext.test4j.hamcrest.Factory;
import ext.test4j.hamcrest.Matcher;

/**
 * Is the value null?
 */
public class IsNull extends BaseMatcher {
    public boolean matches(Object o) {
        return o == null;
    }

    public void describeTo(Description description) {
        description.appendText("null");
    }

    /**
     * Matches if value is null.
     */
    @Factory
    public static Matcher nullValue() {
        return new IsNull();
    }

    /**
     * Matches if value is not null.
     */
    @Factory
    public static Matcher notNullValue() {
        return not(nullValue());
    }

    /**
     * Matches if value is null. With type inference.
     */
    @Factory
    public static  Matcher nullValue(Class type) {
        return new IsNull();
    }

    /**
     * Matches if value is not null. With type inference.
     */
    @Factory
    public static  Matcher notNullValue(Class type) {
        return not(nullValue(type));
    }
}