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

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

package net.bytebuddy.matcher;

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;

/**
 * A method matcher that is resolved by handing over the instrumented type before the matcher is applied to a method.
 */
public interface LatentMethodMatcher {

    /**
     * Resolves the latent method matcher.
     *
     * @param instrumentedType The instrumented type.
     * @return An resolved element matcher for matching a method description.
     */
    ElementMatcher resolve(TypeDescription instrumentedType);

    /**
     * A latent method matcher that is already resolved.
     */
    class Resolved implements LatentMethodMatcher {

        /**
         * The resolved method matcher.
         */
        private final ElementMatcher methodMatcher;

        /**
         * Creates a new resolved latent method matcher.
         *
         * @param methodMatcher The resolved method matcher.
         */
        public Resolved(ElementMatcher methodMatcher) {
            this.methodMatcher = methodMatcher;
        }

        @Override
        public ElementMatcher resolve(TypeDescription instrumentedType) {
            return methodMatcher;
        }

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

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

        @Override
        public String toString() {
            return "LatentMethodMatcher.Resolved{" +
                    "methodMatcher=" + methodMatcher +
                    '}';
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy