/*
 * Copyright 2015-2019 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
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

package org.junit.jupiter.api;

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

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Optional;

import org.apiguardian.api.API;

MethodDescriptor encapsulates functionality for a given Method.
See Also:
Since:5.4
/** * {@link MethodDescriptor} encapsulates functionality for a given {@link Method}. * * @since 5.4 * @see MethodOrdererContext */
@API(status = EXPERIMENTAL, since = "5.4") public interface MethodDescriptor {
Get the method for this descriptor.
Returns:the method; never null
/** * Get the method for this descriptor. * * @return the method; never {@code null} */
Method getMethod();
Determine if an annotation of annotationType is either present or meta-present on the Method for this descriptor.
Params:
  • annotationType – the annotation type to search for; never null
See Also:
Returns:true if the annotation is present or meta-present
/** * Determine if an annotation of {@code annotationType} is either * <em>present</em> or <em>meta-present</em> on the {@link Method} for * this descriptor. * * @param annotationType the annotation type to search for; never {@code null} * @return {@code true} if the annotation is present or meta-present * @see #findAnnotation(Class) * @see #findRepeatableAnnotations(Class) */
boolean isAnnotated(Class<? extends Annotation> annotationType);
Find the first annotation of annotationType that is either present or meta-present on the Method for this descriptor.
Params:
  • annotationType – the annotation type to search for; never null
Type parameters:
  • <A> – the annotation type
See Also:
Returns:an Optional containing the annotation; never null but potentially empty
/** * Find the first annotation of {@code annotationType} that is either * <em>present</em> or <em>meta-present</em> on the {@link Method} for * this descriptor. * * @param <A> the annotation type * @param annotationType the annotation type to search for; never {@code null} * @return an {@code Optional} containing the annotation; never {@code null} but * potentially empty * @see #isAnnotated(Class) * @see #findRepeatableAnnotations(Class) */
<A extends Annotation> Optional<A> findAnnotation(Class<A> annotationType);
Find all repeatable annotations of annotationType that are either present or meta-present on the Method for this descriptor.
Params:
  • annotationType – the repeatable annotation type to search for; never null
Type parameters:
  • <A> – the annotation type
See Also:
Returns:the list of all such annotations found; neither null nor mutable, but potentially empty
/** * Find all <em>repeatable</em> {@linkplain Annotation annotations} of * {@code annotationType} that are either <em>present</em> or * <em>meta-present</em> on the {@link Method} for this descriptor. * * @param <A> the annotation type * @param annotationType the repeatable annotation type to search for; never * {@code null} * @return the list of all such annotations found; neither {@code null} nor * mutable, but potentially empty * @see #isAnnotated(Class) * @see #findAnnotation(Class) * @see java.lang.annotation.Repeatable */
<A extends Annotation> List<A> findRepeatableAnnotations(Class<A> annotationType); }