Skip to content

Commit 1745a3f

Browse files
committed
Consistent @nullable declarations on overridden converter methods
1 parent e417318 commit 1745a3f

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ public NoOpConverter(String name) {
687687
}
688688

689689
@Override
690+
@Nullable
690691
public Set<ConvertiblePair> getConvertibleTypes() {
691692
return null;
692693
}

spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,12 +61,12 @@ public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
6161
}
6262

6363
@Override
64-
@SuppressWarnings("unchecked")
6564
@Nullable
6665
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
6766
if (source == null) {
6867
return null;
6968
}
69+
@SuppressWarnings("unchecked")
7070
Map<Object, Object> sourceMap = (Map<Object, Object>) source;
7171

7272
// Shortcut if possible...

spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Set;
2121

2222
import org.springframework.core.convert.converter.Converter;
23+
import org.springframework.lang.Nullable;
2324

2425
/**
2526
* Converts String to a Boolean.
@@ -48,6 +49,7 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
4849

4950

5051
@Override
52+
@Nullable
5153
public Boolean convert(String source) {
5254
String value = source.trim();
5355
if (value.isEmpty()) {

spring-core/src/main/java/org/springframework/core/convert/support/StringToCharacterConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.core.convert.support;
1818

1919
import org.springframework.core.convert.converter.Converter;
20+
import org.springframework.lang.Nullable;
2021

2122
/**
2223
* Converts a String to a Character.
@@ -27,6 +28,7 @@
2728
final class StringToCharacterConverter implements Converter<String, Character> {
2829

2930
@Override
31+
@Nullable
3032
public Character convert(String source) {
3133
if (source.isEmpty()) {
3234
return null;

spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import org.springframework.core.convert.converter.Converter;
2020
import org.springframework.core.convert.converter.ConverterFactory;
21+
import org.springframework.lang.Nullable;
2122

2223
/**
2324
* Converts from a String to a {@link java.lang.Enum} by calling {@link Enum#valueOf(Class, String)}.
@@ -44,6 +45,7 @@ public StringToEnum(Class<T> enumType) {
4445
}
4546

4647
@Override
48+
@Nullable
4749
public T convert(String source) {
4850
if (source.isEmpty()) {
4951
// It's an empty enum identifier: reset the enum value to null.

spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import org.springframework.core.convert.converter.Converter;
2020
import org.springframework.core.convert.converter.ConverterFactory;
21+
import org.springframework.lang.Nullable;
2122
import org.springframework.util.NumberUtils;
2223

2324
/**
@@ -55,6 +56,7 @@ public StringToNumber(Class<T> targetType) {
5556
}
5657

5758
@Override
59+
@Nullable
5860
public T convert(String source) {
5961
if (source.isEmpty()) {
6062
return null;

0 commit comments

Comments
 (0)