All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ui4j.bytebuddy.matcher.EqualityMatcher Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package com.ui4j.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 - 2024 Weber Informatics LLC | Privacy Policy