31 lines
683 B
Java
31 lines
683 B
Java
package org.bukkit.support;
|
|
|
|
import org.hamcrest.BaseMatcher;
|
|
import org.hamcrest.Description;
|
|
import org.hamcrest.Matcher;
|
|
|
|
public final class Matchers {
|
|
|
|
private Matchers() {}
|
|
|
|
public static <T> Matcher<T> sameHash(T value) {
|
|
return new SameHash<T>(value);
|
|
}
|
|
|
|
static class SameHash<T> extends BaseMatcher<T> {
|
|
private final int expected;
|
|
|
|
SameHash(T object) {
|
|
expected = object.hashCode();
|
|
}
|
|
|
|
public boolean matches(Object item) {
|
|
return item.hashCode() == expected;
|
|
}
|
|
|
|
public void describeTo(Description description) {
|
|
description.appendValue(expected);
|
|
}
|
|
}
|
|
}
|