org.hamcrest
Class CoreMatchers

java.lang.Object
  extended by org.hamcrest.CoreMatchers

public class CoreMatchers
extends Object


Constructor Summary
CoreMatchers()
           
 
Method Summary
static
<T> Matcher<T>
allOf(Iterable<Matcher<? extends T>> matchers)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> Matcher<T>
allOf(Matcher<? extends T>... matchers)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> Matcher<T>
any(Class<T> type)
          This matcher always evaluates to true.
static
<T> Matcher<T>
anyOf(Iterable<Matcher<? extends T>> matchers)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> Matcher<T>
anyOf(Matcher<? extends T>... matchers)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> Matcher<T>
anything()
          This matcher always evaluates to true.
static
<T> Matcher<T>
anything(String description)
          This matcher always evaluates to true.
static
<T> Matcher<T>
describedAs(String description, Matcher<T> matcher, Object... values)
          Wraps an existing matcher and overrides the description when it fails.
static
<T> Matcher<T>
equalTo(T operand)
          Is the value equal to another value, as tested by the Object.equals(java.lang.Object) invokedMethod?
static Matcher<Object> instanceOf(Class<?> type)
          Is the value an instance of a particular type?
static Matcher<Object> is(Class<?> type)
          This is a shortcut to the frequently used is(instanceOf(SomeClass.class)).
static
<T> Matcher<T>
is(Matcher<T> matcher)
          Decorates another Matcher, retaining the behavior but allowing tests to be slightly more expressive.
static
<T> Matcher<T>
is(T value)
          This is a shortcut to the frequently used is(equalTo(x)).
static
<T> Matcher<T>
not(Matcher<T> matcher)
          Inverts the rule.
static
<T> Matcher<T>
not(T value)
          This is a shortcut to the frequently used not(equalTo(x)).
static
<T> Matcher<T>
notNullValue()
          Matches if value is not null.
static
<T> Matcher<T>
notNullValue(Class<T> type)
          Matches if value is not null.
static
<T> Matcher<T>
nullValue()
          Matches if value is null.
static
<T> Matcher<T>
nullValue(Class<T> type)
          Matches if value is null.
static
<T> Matcher<T>
sameInstance(T object)
          Creates a new instance of IsSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoreMatchers

public CoreMatchers()
Method Detail

is

public static <T> Matcher<T> is(Matcher<T> matcher)
Decorates another Matcher, retaining the behavior but allowing tests to be slightly more expressive. eg. assertThat(cheese, equalTo(smelly)) vs assertThat(cheese, is(equalTo(smelly)))


is

public static <T> Matcher<T> is(T value)
This is a shortcut to the frequently used is(equalTo(x)). eg. assertThat(cheese, is(equalTo(smelly))) vs assertThat(cheese, is(smelly))


is

public static Matcher<Object> is(Class<?> type)
This is a shortcut to the frequently used is(instanceOf(SomeClass.class)). eg. assertThat(cheese, is(instanceOf(Cheddar.class))) vs assertThat(cheese, is(Cheddar.class))


not

public static <T> Matcher<T> not(Matcher<T> matcher)
Inverts the rule.


not

public static <T> Matcher<T> not(T value)
This is a shortcut to the frequently used not(equalTo(x)). eg. assertThat(cheese, is(not(equalTo(smelly)))) vs assertThat(cheese, is(not(smelly)))


equalTo

public static <T> Matcher<T> equalTo(T operand)
Is the value equal to another value, as tested by the Object.equals(java.lang.Object) invokedMethod?


instanceOf

public static Matcher<Object> instanceOf(Class<?> type)
Is the value an instance of a particular type?


allOf

public static <T> Matcher<T> allOf(Matcher<? extends T>... matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> Matcher<T> allOf(Iterable<Matcher<? extends T>> matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


anyOf

public static <T> Matcher<T> anyOf(Matcher<? extends T>... matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> Matcher<T> anyOf(Iterable<Matcher<? extends T>> matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.


sameInstance

public static <T> Matcher<T> sameInstance(T object)
Creates a new instance of IsSame

Parameters:
object - The predicate evaluates to true only when the argument is this object.

anything

public static <T> Matcher<T> anything()
This matcher always evaluates to true.


anything

public static <T> Matcher<T> anything(String description)
This matcher always evaluates to true.

Parameters:
description - A meaningful string used when describing itself.

any

public static <T> Matcher<T> any(Class<T> type)
This matcher always evaluates to true. With type inference.


nullValue

public static <T> Matcher<T> nullValue()
Matches if value is null.


nullValue

public static <T> Matcher<T> nullValue(Class<T> type)
Matches if value is null. With type inference.


notNullValue

public static <T> Matcher<T> notNullValue()
Matches if value is not null.


notNullValue

public static <T> Matcher<T> notNullValue(Class<T> type)
Matches if value is not null. With type inference.


describedAs

public static <T> Matcher<T> describedAs(String description,
                                         Matcher<T> matcher,
                                         Object... values)
Wraps an existing matcher and overrides the description when it fails.