Skip to content

Commit d533eb4

Browse files
committed
Use Set.of() in StringToBooleanConverter
1 parent 613aac5 commit d533eb4

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -16,36 +16,24 @@
1616

1717
package org.springframework.core.convert.support;
1818

19-
import java.util.HashSet;
2019
import java.util.Set;
2120

2221
import org.springframework.core.convert.converter.Converter;
2322
import org.springframework.lang.Nullable;
2423

2524
/**
26-
* Converts String to a Boolean.
25+
* Converts a String to a Boolean.
2726
*
2827
* @author Keith Donald
2928
* @author Juergen Hoeller
29+
* @author Sam Brannen
3030
* @since 3.0
3131
*/
3232
final class StringToBooleanConverter implements Converter<String, Boolean> {
3333

34-
private static final Set<String> trueValues = new HashSet<>(8);
34+
private static final Set<String> trueValues = Set.of("true", "on", "yes", "1");
3535

36-
private static final Set<String> falseValues = new HashSet<>(8);
37-
38-
static {
39-
trueValues.add("true");
40-
trueValues.add("on");
41-
trueValues.add("yes");
42-
trueValues.add("1");
43-
44-
falseValues.add("false");
45-
falseValues.add("off");
46-
falseValues.add("no");
47-
falseValues.add("0");
48-
}
36+
private static final Set<String> falseValues = Set.of("false", "off", "no", "0");
4937

5038

5139
@Override

0 commit comments

Comments
 (0)