net.bytebuddy.matcher.EqualityMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of byte-buddy-dep Show documentation
Show all versions of byte-buddy-dep Show documentation
Byte Buddy is a Java library for creating Java classes at run time.
This artifact is a build of Byte Buddy with a remaining dependency onto ASM.
You should never depend on this module without repackaging Byte Buddy and ASM into your own namespace.
package net.bytebuddy.matcher;
/**
* An element matcher that checks an object's equality to another object.
*
* @param The type of the matched entity.
*/
public class EqualityMatcher extends ElementMatcher.Junction.AbstractBase {
/**
* The object that is checked to be equal to the matched value.
*/
private final Object value;
/**
* Creates an element matcher that tests for equality.
*
* @param value The object that is checked to be equal to the matched value.
*/
public EqualityMatcher(Object value) {
this.value = value;
}
@Override
public boolean matches(T target) {
return value.equals(target);
}
@Override
public boolean equals(Object other) {
return this == other || !(other == null || getClass() != other.getClass())
&& value.equals(((EqualityMatcher) other).value);
}
@Override
public int hashCode() {
return value.hashCode();
}
@Override
public String toString() {
return "is(" + value + ")";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy