Skip to content

Commit

Permalink
refactor: Apply @Nullable annotation to spoon.support.util (#5537)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenax66 committed Jan 2, 2024
1 parent 45cccf5 commit 94bfd33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/spoon/support/util/RtHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package spoon.support.util;

import org.jspecify.annotations.Nullable;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLiteral;
Expand Down Expand Up @@ -179,7 +180,7 @@ public static Collection<CtExecutableReference<?>> getAllExecutables(Class<?> cl
* @param numParams
* @return the found method or null
*/
public static Method getMethod(Class<?> clazz, String methodName, int numParams) {
public static @Nullable Method getMethod(Class<?> clazz, String methodName, int numParams) {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (!method.isSynthetic() && method.getName().equals(methodName)) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/spoon/support/util/internal/ElementNameMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.jspecify.annotations.Nullable;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.path.CtRole;
import spoon.support.modelobs.FineModelChangeListener;
Expand Down Expand Up @@ -91,7 +92,7 @@ protected ElementNameMap() {
* if the element is actually replaced.
*/
@Override
public T put(String key, T e) {
public @Nullable T put(String key, T e) {
if (e == null) {
return null;
}
Expand All @@ -107,12 +108,12 @@ public T put(String key, T e) {
return valueOrNull(map.put(key, wrapper));
}

private T valueOrNull(InsertOrderWrapper<T> wrapper) {
private @Nullable T valueOrNull(InsertOrderWrapper<T> wrapper) {
return wrapper != null ? wrapper.value : null;
}

@Override
public T remove(Object key) {
public @Nullable T remove(Object key) {
T removed = valueOrNull(map.remove(key));

if (removed == null) {
Expand Down Expand Up @@ -165,7 +166,7 @@ public boolean containsKey(Object key) {
}

@Override
public T get(Object key) {
public @Nullable T get(Object key) {
InsertOrderWrapper<T> wrapper = map.get(key);
if (wrapper == null) {
return null;
Expand Down

0 comments on commit 94bfd33

Please sign in to comment.