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

org.mockito.internal.creation.bytebuddy.BytecodeGenerator Maven / Gradle / Ivy

/*
 * Copyright (c) 2016 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito.internal.creation.bytebuddy;

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;

import static net.bytebuddy.matcher.ElementMatchers.*;
import static net.bytebuddy.matcher.ElementMatchers.named;

public interface BytecodeGenerator {

     Class mockClass(MockFeatures features);

    void mockClassConstruction(Class type);

    void mockClassStatic(Class type);

    default void clearAllCaches() {}

    static ElementMatcher isGroovyMethod(boolean inline) {
        ElementMatcher.Junction matcher =
                isDeclaredBy(named("groovy.lang.GroovyObjectSupport"))
                        .or(isAnnotatedWith(named("groovy.transform.Internal")));
        if (inline) {
            return matcher.or(
                    named("$getStaticMetaClass").and(returns(named("groovy.lang.MetaClass"))));
        } else {
            return matcher;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy