Polishing

This commit is contained in:
Juergen Hoeller
2020-09-14 23:46:49 +02:00
parent bb5b12af3b
commit 7056dd599f
5 changed files with 56 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@@ -30,9 +30,9 @@ import org.springframework.core.convert.converter.Converter;
*/
final class StringToBooleanConverter implements Converter<String, Boolean> {
private static final Set<String> trueValues = new HashSet<String>(4);
private static final Set<String> trueValues = new HashSet<String>(8);
private static final Set<String> falseValues = new HashSet<String>(4);
private static final Set<String> falseValues = new HashSet<String>(8);
static {
trueValues.add("true");
@@ -46,10 +46,11 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
falseValues.add("0");
}
@Override
public Boolean convert(String source) {
String value = source.trim();
if ("".equals(value)) {
if (value.isEmpty()) {
return null;
}
value = value.toLowerCase();