Skip to content

Commit a8229d8

Browse files
committed
Move @Nullable to return type for methods
1 parent 1754400 commit a8229d8

File tree

65 files changed

+149
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+149
-265
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ public AssertionFailedError build() {
164164
: new AssertionFailedError(message, cause);
165165
}
166166

167-
@Nullable
168-
private static String nullSafeGet(@Nullable Object messageOrSupplier) {
167+
private static @Nullable String nullSafeGet(@Nullable Object messageOrSupplier) {
169168
if (messageOrSupplier == null) {
170169
return null;
171170
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ static void fail(Supplier<@Nullable String> messageSupplier) {
5151
throw new AssertionFailedError(nullSafeGet(messageSupplier));
5252
}
5353

54-
@Nullable
55-
static String nullSafeGet(@Nullable Supplier<@Nullable String> messageSupplier) {
54+
static @Nullable String nullSafeGet(@Nullable Supplier<@Nullable String> messageSupplier) {
5655
return (messageSupplier != null ? messageSupplier.get() : null);
5756
}
5857

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ private static Optional<IndicativeSentencesGeneration> findIndicativeSentencesGe
501501
return findAnnotation(testClass, IndicativeSentencesGeneration.class, enclosingInstanceTypes);
502502
}
503503

504-
@Nullable
505-
private static String getSentenceFragment(AnnotatedElement element) {
504+
private static @Nullable String getSentenceFragment(AnnotatedElement element) {
506505
return findAnnotation(element, SentenceFragment.class) //
507506
.map(SentenceFragment::value) //
508507
.map(sentenceFragment -> {

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/DisabledIfEnvironmentVariableCondition.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ protected ConditionEvaluationResult evaluate(DisabledIfEnvironmentVariable annot
6868
* {@link System#getenv(String)}. Can be overridden in a subclass for
6969
* testing purposes.
7070
*/
71-
@Nullable
72-
protected String getEnvironmentVariable(String name) {
71+
protected @Nullable String getEnvironmentVariable(String name) {
7372
return System.getenv(name);
7473
}
7574

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableCondition.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ protected ConditionEvaluationResult evaluate(EnabledIfEnvironmentVariable annota
6767
* {@link System#getenv(String)}. Can be overridden in a subclass for
6868
* testing purposes.
6969
*/
70-
@Nullable
71-
protected String getEnvironmentVariable(String name) {
70+
protected @Nullable String getEnvironmentVariable(String name) {
7271
return System.getenv(name);
7372
}
7473

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/OS.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,15 @@ public enum OS {
104104
* @since 5.9
105105
*/
106106
@API(status = STABLE, since = "5.10")
107-
@Nullable
108-
public static OS current() {
107+
public static @Nullable OS current() {
109108
return CURRENT_OS;
110109
}
111110

112-
@Nullable
113-
private static OS determineCurrentOs() {
111+
private static @Nullable OS determineCurrentOs() {
114112
return parse(System.getProperty("os.name"));
115113
}
116114

117-
@Nullable
118-
static OS parse(String osName) {
115+
static @Nullable OS parse(String osName) {
119116
if (StringUtils.isBlank(osName)) {
120117
logger.debug(
121118
() -> "JVM system property 'os.name' is undefined. It is therefore not possible to detect the current OS.");

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ExecutableInvoker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public interface ExecutableInvoker {
3434
* @param method the method to invoke and resolve parameters for
3535
* @see #invoke(Method, Object)
3636
*/
37-
@Nullable
38-
default Object invoke(Method method) {
37+
default @Nullable Object invoke(Method method) {
3938
return invoke(method, null);
4039
}
4140

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ExtensionContext.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,7 @@ interface CloseableResource {
555555
* @see #get(Object)
556556
* @see #getOrDefault(Object, Class, Object)
557557
*/
558-
@Nullable
559-
<V> V get(Object key, Class<V> requiredType);
558+
<V> @Nullable V get(Object key, Class<V> requiredType);
560559

561560
/**
562561
* Get the value of the specified required type that is stored under
@@ -653,8 +652,7 @@ default <V> V getOrComputeIfAbsent(Class<V> type) {
653652
* @see CloseableResource
654653
* @see AutoCloseable
655654
*/
656-
@Nullable
657-
<K, V> Object getOrComputeIfAbsent(K key, Function<K, @Nullable V> defaultCreator);
655+
<K, V> @Nullable Object getOrComputeIfAbsent(K key, Function<K, @Nullable V> defaultCreator);
658656

659657
/**
660658
* Get the value of the specified required type that is stored under the
@@ -685,8 +683,7 @@ default <V> V getOrComputeIfAbsent(Class<V> type) {
685683
* @see CloseableResource
686684
* @see AutoCloseable
687685
*/
688-
@Nullable
689-
<K, V> V getOrComputeIfAbsent(K key, Function<K, @Nullable V> defaultCreator, Class<V> requiredType);
686+
<K, V> @Nullable V getOrComputeIfAbsent(K key, Function<K, @Nullable V> defaultCreator, Class<V> requiredType);
690687

691688
/**
692689
* Store a {@code value} for later retrieval under the supplied {@code key}.
@@ -742,8 +739,7 @@ default <V> V getOrComputeIfAbsent(Class<V> type) {
742739
* for the specified key
743740
* @see #remove(Object)
744741
*/
745-
@Nullable
746-
<V> V remove(Object key, Class<V> requiredType);
742+
<V> @Nullable V remove(Object key, Class<V> requiredType);
747743

748744
}
749745

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/InvocationInterceptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ default void interceptTestMethod(Invocation<@Nullable Void> invocation,
143143
* @return the result of the invocation; potentially {@code null}
144144
* @throws Throwable in case of failures
145145
*/
146-
@Nullable
147146
default <T extends @Nullable Object> T interceptTestFactoryMethod(Invocation<T> invocation,
148147
ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
149148
return invocation.proceed();

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/support/TypeBasedParameterResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ private Type enclosedTypeOfParameterResolver() {
6161
return typeBasedParameterResolverSuperclass.getActualTypeArguments()[0];
6262
}
6363

64-
@Nullable
65-
private ParameterizedType findTypeBasedParameterResolverSuperclass(Class<?> clazz) {
64+
private @Nullable ParameterizedType findTypeBasedParameterResolverSuperclass(Class<?> clazz) {
6665
Class<?> superclass = clazz.getSuperclass();
6766

6867
// Abort?

0 commit comments

Comments
 (0)