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

net.bytebuddy.matcher.ErasureMatcher Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
package net.bytebuddy.matcher;

import net.bytebuddy.build.HashCodeAndEqualsPlugin;
import net.bytebuddy.description.type.TypeDefinition;
import net.bytebuddy.description.type.TypeDescription;

/**
 * An element matcher that matches its argument's {@link TypeDescription.Generic} raw type against the
 * given matcher for a {@link TypeDescription}. As a wildcard does not define an erasure, a runtime
 * exception is thrown when this matcher is applied to a wildcard.
 *
 * @param  The type of the matched entity.
 */
@HashCodeAndEqualsPlugin.Enhance
public class ErasureMatcher extends ElementMatcher.Junction.AbstractBase {

    /**
     * The matcher to apply to the raw type of the matched element.
     */
    private final ElementMatcher matcher;

    /**
     * Creates a new raw type matcher.
     *
     * @param matcher The matcher to apply to the raw type.
     */
    public ErasureMatcher(ElementMatcher matcher) {
        this.matcher = matcher;
    }

    @Override
    public boolean matches(T target) {
        return matcher.matches(target.asErasure());
    }

    @Override
    public String toString() {
        return "erasure(" + matcher + ")";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy