forked from mockito/mockito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotNull.java
36 lines (27 loc) · 780 Bytes
/
NotNull.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* 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<T> implements ArgumentMatcher<T>, Serializable {
public static final NotNull<Object> NOT_NULL = new NotNull<>(Object.class);
private final Class<T> type;
public NotNull(Class<T> type) {
this.type = Objects.requireNonNull(type);
}
@Override
public boolean matches(Object actual) {
return actual != null;
}
@Override
public Class<T> type() {
return type;
}
@Override
public String toString() {
return "notNull()";
}
}