com.fitbur.mockito.bytebuddy.matcher.NameMatcher Maven / Gradle / Ivy
package com.fitbur.mockito.bytebuddy.matcher;
import com.fitbur.mockito.bytebuddy.description.NamedElement;
/**
* A method matcher that matches a byte code element's source code name:
*
* - The source code name of types is equal to their binary name where arrays are appended a {@code []} by
* their arity and where inner classes are appended by dots to their outer class's source name.
* - Constructors and the type initializer methods are represented by the empty string as they do not
* represent a source code name.
* - Fields are named as in the source code.
*
*
* @param The type of the matched entity.
*/
public class NameMatcher extends ElementMatcher.Junction.AbstractBase {
/**
* The matcher that is applied to a byte code element's source code name.
*/
private final ElementMatcher matcher;
/**
* Creates a new matcher for a byte code element's source name.
*
* @param matcher The matcher that is applied to a byte code element's source code name.
*/
public NameMatcher(ElementMatcher matcher) {
this.matcher = matcher;
}
@Override
public boolean matches(T target) {
return matcher.matches(target.getActualName());
}
@Override
public boolean equals(Object other) {
return this == other || !(other == null || getClass() != other.getClass())
&& matcher.equals(((NameMatcher>) other).matcher);
}
@Override
public int hashCode() {
return matcher.hashCode();
}
@Override
public String toString() {
return "name(" + matcher + ")";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy