org.hamcrest.core.IsSame Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
/* Copyright (c) 2000-2006 hamcrest.org
*/
package org.hamcrest.core;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
/**
* Is the value the same object as another value?
*/
public class IsSame extends BaseMatcher {
private final T object;
public IsSame(T object) {
this.object = object;
}
@Override
public boolean matches(Object arg) {
return arg == object;
}
@Override
public void describeTo(Description description) {
description.appendText("sameInstance(")
.appendValue(object)
.appendText(")");
}
/**
* Creates a matcher that matches only when the examined object is the same instance as
* the specified target object.
*
* @param target
* the target instance against which others should be assessed
*/
@Factory
public static Matcher sameInstance(T target) {
return new IsSame(target);
}
/**
* Creates a matcher that matches only when the examined object is the same instance as
* the specified target object.
*
* @param target
* the target instance against which others should be assessed
*/
@Factory
public static Matcher theInstance(T target) {
return new IsSame(target);
}
}