Browse Source

Polish

pull/31542/head
Stéphane Nicoll 1 year ago
parent
commit
9c5dcad0e5
  1. 10
      spring-core/src/main/java/org/springframework/util/AntPathMatcher.java
  2. 4
      spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java
  3. 4
      spring-core/src/main/java/org/springframework/util/Base64Utils.java
  4. 6
      spring-core/src/main/java/org/springframework/util/ClassUtils.java
  5. 1
      spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java
  6. 6
      spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
  7. 8
      spring-core/src/main/java/org/springframework/util/DigestUtils.java
  8. 6
      spring-core/src/main/java/org/springframework/util/FileSystemUtils.java
  9. 5
      spring-core/src/main/java/org/springframework/util/MimeType.java
  10. 2
      spring-core/src/main/java/org/springframework/util/ObjectUtils.java
  11. 4
      spring-core/src/main/java/org/springframework/util/StringUtils.java
  12. 3
      spring-core/src/main/java/org/springframework/util/StringValueResolver.java
  13. 8
      spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java
  14. 3
      spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java
  15. 5
      spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureAdapter.java
  16. 4
      spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java

10
spring-core/src/main/java/org/springframework/util/AntPathMatcher.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -402,7 +402,7 @@ public class AntPathMatcher implements PathMatcher { @@ -402,7 +402,7 @@ public class AntPathMatcher implements PathMatcher {
protected String[] tokenizePattern(String pattern) {
String[] tokenized = null;
Boolean cachePatterns = this.cachePatterns;
if (cachePatterns == null || cachePatterns.booleanValue()) {
if (cachePatterns == null || cachePatterns) {
tokenized = this.tokenizedPatternCache.get(pattern);
}
if (tokenized == null) {
@ -414,7 +414,7 @@ public class AntPathMatcher implements PathMatcher { @@ -414,7 +414,7 @@ public class AntPathMatcher implements PathMatcher {
deactivatePatternCache();
return tokenized;
}
if (cachePatterns == null || cachePatterns.booleanValue()) {
if (cachePatterns == null || cachePatterns) {
this.tokenizedPatternCache.put(pattern, tokenized);
}
}
@ -458,7 +458,7 @@ public class AntPathMatcher implements PathMatcher { @@ -458,7 +458,7 @@ public class AntPathMatcher implements PathMatcher {
protected AntPathStringMatcher getStringMatcher(String pattern) {
AntPathStringMatcher matcher = null;
Boolean cachePatterns = this.cachePatterns;
if (cachePatterns == null || cachePatterns.booleanValue()) {
if (cachePatterns == null || cachePatterns) {
matcher = this.stringMatcherCache.get(pattern);
}
if (matcher == null) {
@ -470,7 +470,7 @@ public class AntPathMatcher implements PathMatcher { @@ -470,7 +470,7 @@ public class AntPathMatcher implements PathMatcher {
deactivatePatternCache();
return matcher;
}
if (cachePatterns == null || cachePatterns.booleanValue()) {
if (cachePatterns == null || cachePatterns) {
this.stringMatcherCache.put(pattern, matcher);
}
}

4
spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2023 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.
@ -138,7 +138,7 @@ public class AutoPopulatingList<E> implements List<E>, Serializable { @@ -138,7 +138,7 @@ public class AutoPopulatingList<E> implements List<E>, Serializable {
@Override
public E get(int index) {
int backingListSize = this.backingList.size();
E element = null;
E element;
if (index < backingListSize) {
element = this.backingList.get(index);
if (element == null) {

4
spring-core/src/main/java/org/springframework/util/Base64Utils.java

@ -98,7 +98,7 @@ public abstract class Base64Utils { @@ -98,7 +98,7 @@ public abstract class Base64Utils {
}
/**
* Base64-decode the given byte array from an UTF-8 String.
* Base64-decode the given byte array from a UTF-8 String.
* @param src the encoded UTF-8 String
* @return the original byte array
*/
@ -120,7 +120,7 @@ public abstract class Base64Utils { @@ -120,7 +120,7 @@ public abstract class Base64Utils {
}
/**
* Base64-decode the given byte array from an UTF-8 String using the RFC 4648
* Base64-decode the given byte array from a UTF-8 String using the RFC 4648
* "URL and Filename Safe Alphabet".
* @param src the encoded UTF-8 String
* @return the original byte array

6
spring-core/src/main/java/org/springframework/util/ClassUtils.java

@ -106,19 +106,19 @@ public abstract class ClassUtils { @@ -106,19 +106,19 @@ public abstract class ClassUtils {
/**
* Map with primitive wrapper type as key and corresponding primitive
* type as value, for example: Integer.class -> int.class.
* type as value, for example: {@code Integer.class -> int.class}.
*/
private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new IdentityHashMap<>(9);
/**
* Map with primitive type as key and corresponding wrapper
* type as value, for example: int.class -> Integer.class.
* type as value, for example: {@code int.class -> Integer.class}.
*/
private static final Map<Class<?>, Class<?>> primitiveTypeToWrapperMap = new IdentityHashMap<>(9);
/**
* Map with primitive type name as key and corresponding primitive
* type as value, for example: "int" -> "int.class".
* type as value, for example: {@code "int" -> int.class}.
*/
private static final Map<String, Class<?>> primitiveTypeNameMap = new HashMap<>(32);

1
spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java

@ -396,7 +396,6 @@ public final class ConcurrentLruCache<K, V> { @@ -396,7 +396,6 @@ public final class ConcurrentLruCache<K, V> {
private final EvictionQueue<K, V> evictionQueue;
@SuppressWarnings("rawtypes")
ReadOperations(EvictionQueue<K, V> evictionQueue) {
this.evictionQueue = evictionQueue;
for (int i = 0; i < BUFFER_COUNT; i++) {

6
spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

@ -317,7 +317,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen @@ -317,7 +317,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
}
@Override
public boolean remove(@Nullable Object key, final @Nullable Object value) {
public boolean remove(@Nullable Object key, @Nullable final Object value) {
Boolean result = doTask(key, new Task<Boolean>(TaskOption.RESTRUCTURE_AFTER, TaskOption.SKIP_IF_EMPTY) {
@Override
protected Boolean execute(@Nullable Reference<K, V> ref, @Nullable Entry<K, V> entry) {
@ -334,7 +334,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen @@ -334,7 +334,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
}
@Override
public boolean replace(@Nullable K key, final @Nullable V oldValue, final @Nullable V newValue) {
public boolean replace(@Nullable K key, @Nullable final V oldValue, @Nullable final V newValue) {
Boolean result = doTask(key, new Task<Boolean>(TaskOption.RESTRUCTURE_BEFORE, TaskOption.SKIP_IF_EMPTY) {
@Override
protected Boolean execute(@Nullable Reference<K, V> ref, @Nullable Entry<K, V> entry) {
@ -350,7 +350,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen @@ -350,7 +350,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
@Override
@Nullable
public V replace(@Nullable K key, final @Nullable V value) {
public V replace(@Nullable K key, @Nullable final V value) {
return doTask(key, new Task<V>(TaskOption.RESTRUCTURE_BEFORE, TaskOption.SKIP_IF_EMPTY) {
@Override
@Nullable

8
spring-core/src/main/java/org/springframework/util/DigestUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -125,13 +125,13 @@ public abstract class DigestUtils { @@ -125,13 +125,13 @@ public abstract class DigestUtils {
private static byte[] digest(String algorithm, InputStream inputStream) throws IOException {
MessageDigest messageDigest = getDigest(algorithm);
if (inputStream instanceof UpdateMessageDigestInputStream digestIntputStream){
digestIntputStream.updateMessageDigest(messageDigest);
if (inputStream instanceof UpdateMessageDigestInputStream digestInputStream){
digestInputStream.updateMessageDigest(messageDigest);
return messageDigest.digest();
}
else {
final byte[] buffer = new byte[StreamUtils.BUFFER_SIZE];
int bytesRead = -1;
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
messageDigest.update(buffer, 0, bytesRead);
}

6
spring-core/src/main/java/org/springframework/util/FileSystemUtils.java

@ -84,12 +84,13 @@ public abstract class FileSystemUtils { @@ -84,12 +84,13 @@ public abstract class FileSystemUtils {
return false;
}
Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
Files.walkFileTree(root, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
@ -126,12 +127,13 @@ public abstract class FileSystemUtils { @@ -126,12 +127,13 @@ public abstract class FileSystemUtils {
BasicFileAttributes srcAttr = Files.readAttributes(src, BasicFileAttributes.class);
if (srcAttr.isDirectory()) {
Files.walkFileTree(src, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
Files.walkFileTree(src, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
Files.createDirectories(dest.resolve(src.relativize(dir)));
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.copy(file, dest.resolve(src.relativize(file)), StandardCopyOption.REPLACE_EXISTING);

5
spring-core/src/main/java/org/springframework/util/MimeType.java

@ -102,7 +102,6 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -102,7 +102,6 @@ public class MimeType implements Comparable<MimeType>, Serializable {
private final String subtype;
@SuppressWarnings("serial")
private final Map<String, String> parameters;
@Nullable
@ -642,7 +641,7 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -642,7 +641,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
}
/**
* Indicates whether this {@code MimeType} is more less than the given type.
* Indicates whether this {@code MimeType} is less specific than the given type.
* <ol>
* <li>if this mime type has a {@linkplain #isWildcardType() wildcard type},
* and the other does not, then this method returns {@code true}.</li>
@ -684,7 +683,7 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -684,7 +683,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
/**
* Parse the given String value into a {@code MimeType} object,
* with this method name following the 'valueOf' naming convention
* (as supported by {@link org.springframework.core.convert.ConversionService}.
* (as supported by {@link org.springframework.core.convert.ConversionService}).
* @see MimeTypeUtils#parseMimeType(String)
*/
public static MimeType valueOf(String value) {

2
spring-core/src/main/java/org/springframework/util/ObjectUtils.java

@ -144,7 +144,7 @@ public abstract class ObjectUtils { @@ -144,7 +144,7 @@ public abstract class ObjectUtils {
return optional.isEmpty();
}
if (obj instanceof CharSequence charSequence) {
return charSequence.length() == 0;
return charSequence.isEmpty();
}
if (obj.getClass().isArray()) {
return Array.getLength(obj) == 0;

4
spring-core/src/main/java/org/springframework/util/StringUtils.java

@ -839,7 +839,7 @@ public abstract class StringUtils { @@ -839,7 +839,7 @@ public abstract class StringUtils {
* the {@link Locale#toString} format as well as BCP 47 language tags as
* specified by {@link Locale#forLanguageTag}.
* @param localeValue the locale value: following either {@code Locale's}
* {@code toString()} format ("en", "en_UK", etc), also accepting spaces as
* {@code toString()} format ("en", "en_UK", etc.), also accepting spaces as
* separators (as an alternative to underscores), or BCP 47 (e.g. "en-UK")
* @return a corresponding {@code Locale} instance, or {@code null} if none
* @throws IllegalArgumentException in case of an invalid locale specification
@ -868,7 +868,7 @@ public abstract class StringUtils { @@ -868,7 +868,7 @@ public abstract class StringUtils {
* <p><b>Note: This delegate does not accept the BCP 47 language tag format.
* Please use {@link #parseLocale} for lenient parsing of both formats.</b>
* @param localeString the locale {@code String}: following {@code Locale's}
* {@code toString()} format ("en", "en_UK", etc), also accepting spaces as
* {@code toString()} format ("en", "en_UK", etc.), also accepting spaces as
* separators (as an alternative to underscores)
* @return a corresponding {@code Locale} instance, or {@code null} if none
* @throws IllegalArgumentException in case of an invalid locale specification

3
spring-core/src/main/java/org/springframework/util/StringValueResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2023 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.
@ -26,7 +26,6 @@ import org.springframework.lang.Nullable; @@ -26,7 +26,6 @@ import org.springframework.lang.Nullable;
* @since 2.5
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#resolveAliases
* @see org.springframework.beans.factory.config.BeanDefinitionVisitor#BeanDefinitionVisitor(StringValueResolver)
* @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
*/
@FunctionalInterface
public interface StringValueResolver {

8
spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 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.
@ -35,13 +35,13 @@ import org.springframework.lang.Nullable; @@ -35,13 +35,13 @@ import org.springframework.lang.Nullable;
*/
public abstract class SystemPropertyUtils {
/** Prefix for system property placeholders: "${". */
/** Prefix for system property placeholders: {@value}. */
public static final String PLACEHOLDER_PREFIX = "${";
/** Suffix for system property placeholders: "}". */
/** Suffix for system property placeholders: {@value}. */
public static final String PLACEHOLDER_SUFFIX = "}";
/** Value separator for system property placeholders: ":". */
/** Value separator for system property placeholders: {@value}. */
public static final String VALUE_SEPARATOR = ":";

3
spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java

@ -47,7 +47,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -47,7 +47,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
private static final long serialVersionUID = -8697084563854098920L;
@SuppressWarnings("serial")
private final MultiValueMap<K, V> delegate;
@Nullable
@ -266,7 +265,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -266,7 +265,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
private static final long serialVersionUID = 2407578793783925203L;
@SuppressWarnings("serial")
private final Set<Entry<K, List<V>>> delegate;
@SuppressWarnings("unchecked")
@ -516,7 +514,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial @@ -516,7 +514,6 @@ final class UnmodifiableMultiValueMap<K,V> implements MultiValueMap<K,V>, Serial
private static final long serialVersionUID = 5518377583904339588L;
@SuppressWarnings("serial")
private final Collection<List<V>> delegate;
public UnmodifiableValueCollection(Collection<List<V>> delegate) {

5
spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureAdapter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -54,7 +54,7 @@ public abstract class ListenableFutureAdapter<T, S> extends FutureAdapter<T, S> @@ -54,7 +54,7 @@ public abstract class ListenableFutureAdapter<T, S> extends FutureAdapter<T, S>
@Override
public void addCallback(final SuccessCallback<? super T> successCallback, final FailureCallback failureCallback) {
ListenableFuture<S> listenableAdaptee = (ListenableFuture<S>) getAdaptee();
listenableAdaptee.addCallback(new ListenableFutureCallback<S>() {
listenableAdaptee.addCallback(new ListenableFutureCallback<>() {
@Override
public void onSuccess(@Nullable S result) {
T adapted = null;
@ -74,6 +74,7 @@ public abstract class ListenableFutureAdapter<T, S> extends FutureAdapter<T, S> @@ -74,6 +74,7 @@ public abstract class ListenableFutureAdapter<T, S> extends FutureAdapter<T, S>
}
successCallback.onSuccess(adapted);
}
@Override
public void onFailure(Throwable ex) {
failureCallback.onFailure(ex);

4
spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@ -55,7 +55,7 @@ public abstract class TransformerUtils { @@ -55,7 +55,7 @@ public abstract class TransformerUtils {
* <p>If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount}
* will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters.
* @param transformer the target transformer
* @param indentAmount the size of the indent (2 characters, 3 characters, etc)
* @param indentAmount the size of the indent (2 characters, 3 characters, etc.)
* @see javax.xml.transform.Transformer#setOutputProperty(String, String)
* @see javax.xml.transform.OutputKeys#INDENT
*/

Loading…
Cancel
Save