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

org.mockito.internal.matchers.NotNull Maven / Gradle / Ivy

There is a newer version: 5.12.0
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito.internal.matchers;

import java.io.Serializable;
import java.util.Objects;

import org.mockito.ArgumentMatcher;

public class NotNull implements ArgumentMatcher, Serializable {

    public static final NotNull NOT_NULL = new NotNull<>(Object.class);

    private final Class type;

    public NotNull(Class type) {
        this.type = Objects.requireNonNull(type);
    }

    @Override
    public boolean matches(Object actual) {
        return actual != null;
    }

    @Override
    public Class type() {
        return type;
    }

    @Override
    public String toString() {
        return "notNull()";
    }
}