Top Description Fields Constructors Methods
org.hamcrest.core

public Class IsNot<T>

extends BaseMatcher<T>
Class Inheritance
Imports
org.hamcrest.BaseMatcher, .Description, .Matcher

Calculates the logical negation of a matcher.

Field Summary

Modifier and TypeField and Description
private final Matcher<T>

Constructor Summary

AccessConstructor and Description
public
IsNot(Matcher<T> matcher)

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.
arg
)

Implements org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item.
public static <T> Matcher<T>
not(Matcher<T>
the matcher whose sense should be inverted
matcher
)

Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.

public static <T> Matcher<T>
not(T
the value that any examined object should not equal
value
)

A shortcut to the frequently used not(equalTo(x)).

Inherited from org.hamcrest.BaseMatcher:
_dont_implement_Matcher___instead_extend_BaseMatcher_describeMismatchisNotNulltoString

Field Detail

matcherback to summary
private final Matcher<T> matcher

Constructor Detail

IsNotback to summary
public IsNot(Matcher<T> matcher)

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 arg)

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
arg:Object

the object against which the matcher is evaluated.

Returns:boolean

true if item matches, otherwise false.

Annotations
@Override
notback to summary
public static <T> Matcher<T> not(Matcher<T> matcher)

Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match. For example:

assertThat(cheese, is(not(equalTo(smelly))))
Parameters
matcher:Matcher<T>

the matcher whose sense should be inverted

notback to summary
public static <T> Matcher<T> not(T value)

A shortcut to the frequently used not(equalTo(x)). For example:

assertThat(cheese, is(not(smelly)))
instead of:
assertThat(cheese, is(not(equalTo(smelly))))
Parameters
value:T

the value that any examined object should not equal