Consistent @Nullable declarations on overridden converter methods

This commit is contained in:
Juergen Hoeller
2020-10-07 14:28:45 +02:00
parent 104e941171
commit 01d86dc498
6 changed files with 16 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -642,7 +642,7 @@ public class GenericConversionService implements ConfigurableConversionService {
private List<String> getConverterStrings() {
List<String> converterStrings = new ArrayList<>();
for (ConvertersForPair convertersForPair : converters.values()) {
for (ConvertersForPair convertersForPair : this.converters.values()) {
converterStrings.add(convertersForPair.toString());
}
Collections.sort(converterStrings);
@@ -692,6 +692,7 @@ public class GenericConversionService implements ConfigurableConversionService {
}
@Override
@Nullable
public Set<ConvertiblePair> getConvertibleTypes() {
return null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,12 +61,12 @@ final class MapToMapConverter implements ConditionalGenericConverter {
}
@Override
@SuppressWarnings("unchecked")
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (source == null) {
return null;
}
@SuppressWarnings("unchecked")
Map<Object, Object> sourceMap = (Map<Object, Object>) source;
// Shortcut if possible...

View File

@@ -20,6 +20,7 @@ import java.util.HashSet;
import java.util.Set;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;
/**
* Converts String to a Boolean.
@@ -48,6 +49,7 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
@Override
@Nullable
public Boolean convert(String source) {
String value = source.trim();
if (value.isEmpty()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.core.convert.support;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;
/**
* Converts a String to a Character.
@@ -27,6 +28,7 @@ import org.springframework.core.convert.converter.Converter;
final class StringToCharacterConverter implements Converter<String, Character> {
@Override
@Nullable
public Character convert(String source) {
if (source.isEmpty()) {
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.core.convert.support;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.lang.Nullable;
/**
* Converts from a String to a {@link java.lang.Enum} by calling {@link Enum#valueOf(Class, String)}.
@@ -44,6 +45,7 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
}
@Override
@Nullable
public T convert(String source) {
if (source.isEmpty()) {
// It's an empty enum identifier: reset the enum value to null.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.core.convert.support;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.NumberUtils;
/**
@@ -55,6 +56,7 @@ final class StringToNumberConverterFactory implements ConverterFactory<String, N
}
@Override
@Nullable
public T convert(String source) {
if (source.isEmpty()) {
return null;