// Generated by delombok at Sun Feb 26 12:31:38 KST 2017
package scouter.bytebuddy.matcher;
import scouter.bytebuddy.description.DeclaredByType;
import scouter.bytebuddy.description.type.TypeDefinition;
import scouter.bytebuddy.description.type.TypeDescription;
/**
* An element matcher that matches the declaring type of another element, only if this element is actually declared
* in a type.
*
* @param <T> The exact type of the element being matched.
*/
public class DeclaringTypeMatcher<T extends DeclaredByType> extends ElementMatcher.Junction.AbstractBase<T> {
/**
* The type matcher to be applied if the target element is declared in a type.
*/
private final ElementMatcher<? super TypeDescription.Generic> matcher;
/**
* Creates a new matcher for the declaring type of an element.
*
* @param matcher The type matcher to be applied if the target element is declared in a type.
*/
public DeclaringTypeMatcher(ElementMatcher<? super TypeDescription.Generic> matcher) {
this.matcher = matcher;
}
@Override
public boolean matches(T target) {
TypeDefinition declaringType = target.getDeclaringType();
return declaringType != null && matcher.matches(declaringType.asGenericType());
}
@Override
public String toString() {
return "declaredBy(" + matcher + ")";
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof DeclaringTypeMatcher)) return false;
final DeclaringTypeMatcher<?> other = (DeclaringTypeMatcher<?>) o;
if (!other.canEqual((java.lang.Object) this)) return false;
final java.lang.Object this$matcher = this.matcher;
final java.lang.Object other$matcher = other.matcher;
if (this$matcher == null ? other$matcher != null : !this$matcher.equals(other$matcher)) return false;
return true;
}
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
protected boolean canEqual(final java.lang.Object other) {
return other instanceof DeclaringTypeMatcher;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public int hashCode() {
final int PRIME = 59;
int result = 1;
final java.lang.Object $matcher = this.matcher;
result = result * PRIME + ($matcher == null ? 43 : $matcher.hashCode());
return result;
}
}