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 hamcrest Show documentation
Show all versions of hamcrest Show documentation
Core API and libraries of hamcrest matcher framework.
package org.hamcrest.core;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
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
*/
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
*/
public static Matcher theInstance(T target) {
return new IsSame(target);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy