Browse Source

Consistent @Nullable declarations on overridden converter methods

pull/26319/head
Juergen Hoeller 4 years ago
parent
commit
1745a3f25d
  1. 1
      spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
  2. 4
      spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java
  3. 2
      spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java
  4. 4
      spring-core/src/main/java/org/springframework/core/convert/support/StringToCharacterConverter.java
  5. 4
      spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java
  6. 4
      spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java

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

@ -687,6 +687,7 @@ public class GenericConversionService implements ConfigurableConversionService { @@ -687,6 +687,7 @@ public class GenericConversionService implements ConfigurableConversionService {
}
@Override
@Nullable
public Set<ConvertiblePair> getConvertibleTypes() {
return null;
}

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

@ -1,5 +1,5 @@ @@ -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 { @@ -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...

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

@ -20,6 +20,7 @@ import java.util.HashSet; @@ -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> { @@ -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()) {

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

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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; @@ -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;

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

@ -1,5 +1,5 @@ @@ -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; @@ -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 @@ -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.

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

@ -1,5 +1,5 @@ @@ -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; @@ -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 @@ -55,6 +56,7 @@ final class StringToNumberConverterFactory implements ConverterFactory<String, N
}
@Override
@Nullable
public T convert(String source) {
if (source.isEmpty()) {
return null;

Loading…
Cancel
Save