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

org.junit.jupiter.api.extension.ExecutableInvoker Maven / Gradle / Ivy

There is a newer version: 5.11.3
Show newest version
/*
 * Copyright 2015-2024 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * https://www.eclipse.org/legal/epl-v20.html
 */

package org.junit.jupiter.api.extension;

import static org.apiguardian.api.API.Status.STABLE;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

import org.apiguardian.api.API;

/**
 * {@code ExecutableInvoker} allows invoking methods and constructors
 * with support for dynamic resolution of parameters via
 * {@link ParameterResolver ParameterResolvers}.
 *
 * @since 5.9
 */
@API(status = STABLE, since = "5.11")
public interface ExecutableInvoker {

	/**
	 * Invoke the supplied {@code static} method with dynamic parameter resolution.
	 *
	 * @param method the method to invoke and resolve parameters for
	 * @see #invoke(Method, Object)
	 */
	default Object invoke(Method method) {
		return invoke(method, null);
	}

	/**
	 * Invoke the supplied method with dynamic parameter resolution.
	 *
	 * @param method the method to invoke and resolve parameters for
	 * @param target the target on which the executable will be invoked;
	 * can be {@code null} for {@code static} methods
	 */
	Object invoke(Method method, Object target);

	/**
	 * Invoke the supplied top-level constructor with dynamic parameter resolution.
	 *
	 * @param constructor the constructor to invoke and resolve parameters for
	 * @see #invoke(Constructor, Object)
	 */
	default  T invoke(Constructor constructor) {
		return invoke(constructor, null);
	}

	/**
	 * Invoke the supplied constructor with the supplied outer instance and
	 * dynamic parameter resolution.
	 *
	 * 

Use this method when invoking the constructor for an inner class. * * @param constructor the constructor to invoke and resolve parameters for * @param outerInstance the outer instance to supply as the first argument * to the constructor; must be {@code null} for top-level classes * or {@code static} nested classes */ T invoke(Constructor constructor, Object outerInstance); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy