Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/ClassDescriptor.java

raw symbols SCIP
1 /*
2 * Copyright 2015-2024 the original author or authors.
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v2.0 which
6 * accompanies this distribution and is available at
7 *
8 * https://www.eclipse.org/legal/epl-v20.html
9 */
10
11 package org.junit.jupiter.api;
12
13 import static org.apiguardian.api.API.Status.STABLE;
14
15 import java.lang.annotation.Annotation;
16 import java.util.List;
17 import java.util.Optional;
18
19 import org.apiguardian.api.API;
20
21 /**
22 * {@code ClassDescriptor} encapsulates functionality for a given {@link Class}.
23 *
24 * @since 5.8
25 * @see ClassOrdererContext
26 */
27 @API(status = STABLE, since = "5.10")
28 public interface ClassDescriptor {
29
30 /**
31 * Get the class for this descriptor.
32 *
33 * @return the class; never {@code null}
34 */
35 Class<?> getTestClass();
36
37 /**
38 * Get the display name for this descriptor's {@link #getTestClass() class}.
39 *
40 * @return the display name for this descriptor's class; never {@code null}
41 * or blank
42 */
43 String getDisplayName();
44
45 /**
46 * Determine if an annotation of {@code annotationType} is either
47 * <em>present</em> or <em>meta-present</em> on the {@link Class} for
48 * this descriptor.
49 *
50 * @param annotationType the annotation type to search for; never {@code null}
51 * @return {@code true} if the annotation is present or meta-present
52 * @see #findAnnotation(Class)
53 * @see #findRepeatableAnnotations(Class)
54 */
55 boolean isAnnotated(Class<? extends Annotation> annotationType);
56
57 /**
58 * Find the first annotation of {@code annotationType} that is either
59 * <em>present</em> or <em>meta-present</em> on the {@link Class} for
60 * this descriptor.
61 *
62 * @param <A> the annotation type
63 * @param annotationType the annotation type to search for; never {@code null}
64 * @return an {@code Optional} containing the annotation; never {@code null} but
65 * potentially empty
66 * @see #isAnnotated(Class)
67 * @see #findRepeatableAnnotations(Class)
68 */
69 <A extends Annotation> Optional<A> findAnnotation(Class<A> annotationType);
70
71 /**
72 * Find all <em>repeatable</em> {@linkplain Annotation annotations} of
73 * {@code annotationType} that are either <em>present</em> or
74 * <em>meta-present</em> on the {@link Class} for this descriptor.
75 *
76 * @param <A> the annotation type
77 * @param annotationType the repeatable annotation type to search for; never
78 * {@code null}
79 * @return the list of all such annotations found; neither {@code null} nor
80 * mutable, but potentially empty
81 * @see #isAnnotated(Class)
82 * @see #findAnnotation(Class)
83 * @see java.lang.annotation.Repeatable
84 */
85 <A extends Annotation> List<A> findRepeatableAnnotations(Class<A> annotationType);
86
87 }