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

com.fitbur.bytebuddy.matcher.InheritedAnnotationMatcher Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.bytebuddy.matcher;

import com.fitbur.bytebuddy.description.annotation.AnnotationList;
import com.fitbur.bytebuddy.description.type.TypeDescription;

/**
 * An element matcher that matches the list of inherited annotations of a type description.
 *
 * @param  The actual matched type of this matcher.
 */
public class InheritedAnnotationMatcher extends ElementMatcher.Junction.AbstractBase {

    /**
     * The matcher to be applied to the provided annotation list.
     */
    private final ElementMatcher annotationMatcher;

    /**
     * Creates a new matcher for the inherited annotations of a type description.
     *
     * @param annotationMatcher The matcher to be applied to the provided annotation list.
     */
    public InheritedAnnotationMatcher(ElementMatcher annotationMatcher) {
        this.annotationMatcher = annotationMatcher;
    }

    @Override
    public boolean matches(T target) {
        return annotationMatcher.matches(target.getInheritedAnnotations());
    }

    @Override
    public boolean equals(Object other) {
        return this == other || !(other == null || getClass() != other.getClass())
                && annotationMatcher.equals(((InheritedAnnotationMatcher) other).annotationMatcher);
    }

    @Override
    public int hashCode() {
        return annotationMatcher.hashCode();
    }

    @Override
    public String toString() {
        return "inheritsAnnotations(" + annotationMatcher + ")";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy