Top Description Fields Constructors Methods
org.hamcrest.core

public Class IsSame<T>

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

Is the value the same object as another value?

Field Summary

Modifier and TypeField and Description
private final T

Constructor Summary

AccessConstructor and Description
public
IsSame(T object)

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>
sameInstance(T
the target instance against which others should be assessed
target
)

Creates a matcher that matches only when the examined object is the same instance as the specified target object.

public static <T> Matcher<T>
theInstance(T
the target instance against which others should be assessed
target
)

Creates a matcher that matches only when the examined object is the same instance as the specified target object.

Inherited from org.hamcrest.BaseMatcher:
_dont_implement_Matcher___instead_extend_BaseMatcher_describeMismatchisNotNulltoString

Field Detail

objectback to summary
private final T object

Constructor Detail

IsSameback to summary
public IsSame(T object)

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
sameInstanceback to summary
public static <T> Matcher<T> sameInstance(T target)

Creates a matcher that matches only when the examined object is the same instance as the specified target object.

Parameters
target:T

the target instance against which others should be assessed

theInstanceback to summary
public static <T> Matcher<T> theInstance(T target)

Creates a matcher that matches only when the examined object is the same instance as the specified target object.

Parameters
target:T

the target instance against which others should be assessed