Polishing

This commit is contained in:
Juergen Hoeller
2023-07-19 01:17:25 +02:00
parent 3a8c0dbd8a
commit a7b7466274
22 changed files with 93 additions and 86 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 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.
@@ -252,7 +252,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
@Override
public final boolean containsProperty(String name) {
if (this.nonOptionArgsPropertyName.equals(name)) {
return !this.getNonOptionArgs().isEmpty();
return !getNonOptionArgs().isEmpty();
}
return this.containsOption(name);
}
@@ -270,7 +270,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
@Nullable
public final String getProperty(String name) {
if (this.nonOptionArgsPropertyName.equals(name)) {
Collection<String> nonOptionArguments = this.getNonOptionArgs();
Collection<String> nonOptionArguments = getNonOptionArgs();
if (nonOptionArguments.isEmpty()) {
return null;
}
@@ -278,7 +278,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
return StringUtils.collectionToCommaDelimitedString(nonOptionArguments);
}
}
Collection<String> optionValues = this.getOptionValues(name);
Collection<String> optionValues = getOptionValues(name);
if (optionValues == null) {
return null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 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.
@@ -752,28 +752,27 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
}
@Override
public String toString() {
return (this.key + "=" + this.value);
}
@Override
@SuppressWarnings("rawtypes")
public final boolean equals(@Nullable Object other) {
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Map.Entry)) {
if (!(other instanceof Map.Entry<?, ?>)) {
return false;
}
Map.Entry otherEntry = (Map.Entry) other;
Map.Entry<?, ?> otherEntry = (Map.Entry<?, ?>) other;
return (ObjectUtils.nullSafeEquals(getKey(), otherEntry.getKey()) &&
ObjectUtils.nullSafeEquals(getValue(), otherEntry.getValue()));
}
@Override
public final int hashCode() {
public int hashCode() {
return (ObjectUtils.nullSafeHashCode(this.key) ^ ObjectUtils.nullSafeHashCode(this.value));
}
@Override
public String toString() {
return (this.key + "=" + this.value);
}
}

View File

@@ -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.
@@ -85,7 +85,7 @@ public class NullSafeComparator<T> implements Comparator<T> {
* @param nullsLow whether to treat nulls lower or higher than non-null objects
*/
public NullSafeComparator(Comparator<T> comparator, boolean nullsLow) {
Assert.notNull(comparator, "Non-null Comparator is required");
Assert.notNull(comparator, "Comparator must not be null");
this.nonNullComparator = comparator;
this.nullsLow = nullsLow;
}
@@ -107,16 +107,16 @@ public class NullSafeComparator<T> implements Comparator<T> {
@Override
@SuppressWarnings("unchecked")
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof NullSafeComparator)) {
if (!(other instanceof NullSafeComparator<?>)) {
return false;
}
NullSafeComparator<T> otherComp = (NullSafeComparator<T>) other;
return (this.nonNullComparator.equals(otherComp.nonNullComparator) && this.nullsLow == otherComp.nullsLow);
NullSafeComparator<?> otherComp = (NullSafeComparator<?>) other;
return (this.nonNullComparator.equals(otherComp.nonNullComparator) &&
this.nullsLow == otherComp.nullsLow);
}
@Override

View File

@@ -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.
@@ -28,7 +28,7 @@ import org.springframework.core.env.PropertySource;
*
* The {@link #setProperty} and {@link #withProperty} methods are exposed for
* convenience, for example:
* <pre>
* <pre class="code">
* {@code
* PropertySource<?> source = new MockPropertySource().withProperty("foo", "bar");
* }
@@ -77,7 +77,7 @@ public class MockPropertySource extends PropertiesPropertySource {
/**
* Create a new {@code MockPropertySource} with the given name and backed by the given
* {@link Properties} object
* {@link Properties} object.
* @param name the {@linkplain #getName() name} of the property source
* @param properties the properties to use
*/
@@ -99,7 +99,7 @@ public class MockPropertySource extends PropertiesPropertySource {
* @return this {@link MockPropertySource} instance
*/
public MockPropertySource withProperty(String name, Object value) {
this.setProperty(name, value);
setProperty(name, value);
return this;
}