Merge pull request #1670 from igor-suhorukov
* pr/1670: Collection.isEmpty() should be used to test for emptiness
This commit is contained in:
commit
909cacec42
|
|
@ -72,7 +72,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
|||
CacheNamespaceHandler.parseKeyGenerator(element, builder.getBeanDefinition());
|
||||
|
||||
List<Element> cacheDefs = DomUtils.getChildElementsByTagName(element, DEFS_ELEMENT);
|
||||
if (cacheDefs.size() >= 1) {
|
||||
if (!cacheDefs.isEmpty()) {
|
||||
// Using attributes source.
|
||||
List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
|
||||
builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public abstract class JmxUtils {
|
|||
// null means any registered server, but "" specifically means the platform server
|
||||
if (!"".equals(agentId)) {
|
||||
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(agentId);
|
||||
if (servers != null && servers.size() > 0) {
|
||||
if (servers != null && !servers.isEmpty()) {
|
||||
// Check to see if an MBeanServer is registered.
|
||||
if (servers.size() > 1 && logger.isWarnEnabled()) {
|
||||
logger.warn("Found more than one MBeanServer instance" +
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
|||
*/
|
||||
@Nullable
|
||||
public Validator getValidator() {
|
||||
return (this.validators.size() > 0 ? this.validators.get(0) : null);
|
||||
return (!this.validators.isEmpty() ? this.validators.get(0) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ public class StringDecoder extends AbstractDataBufferDecoder<String> {
|
|||
* Joins the given list of buffers into a single buffer.
|
||||
*/
|
||||
private static Mono<DataBuffer> joinUntilEndFrame(List<DataBuffer> dataBuffers) {
|
||||
if (dataBuffers.size() > 0) {
|
||||
if (!dataBuffers.isEmpty()) {
|
||||
int lastIdx = dataBuffers.size() - 1;
|
||||
if (isEndFrame(dataBuffers.get(lastIdx))) {
|
||||
dataBuffers.remove(lastIdx);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class DatabasePopulatorConfigUtils {
|
|||
|
||||
public static void setDatabasePopulator(Element element, BeanDefinitionBuilder builder) {
|
||||
List<Element> scripts = DomUtils.getChildElementsByTagName(element, "script");
|
||||
if (scripts.size() > 0) {
|
||||
if (!scripts.isEmpty()) {
|
||||
builder.addPropertyValue("databasePopulator", createDatabasePopulator(element, scripts, "INIT"));
|
||||
builder.addPropertyValue("databaseCleaner", createDatabasePopulator(element, scripts, "DESTROY"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ public class CallMetaDataContext {
|
|||
if (this.outParameterNames.size() > 1) {
|
||||
logger.warn("Accessing single output value when procedure has more than one output parameter");
|
||||
}
|
||||
return (this.outParameterNames.size() > 0 ? this.outParameterNames.get(0) : null);
|
||||
return (!this.outParameterNames.isEmpty() ? this.outParameterNames.get(0) : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ public class CallMetaDataContext {
|
|||
SqlParameter param;
|
||||
if (meta.getParameterType() == DatabaseMetaData.procedureColumnReturn) {
|
||||
param = declaredParams.get(getFunctionReturnName());
|
||||
if (param == null && getOutParameterNames().size() > 0) {
|
||||
if (param == null && !getOutParameterNames().isEmpty()) {
|
||||
param = declaredParams.get(getOutParameterNames().get(0).toLowerCase());
|
||||
}
|
||||
if (param == null) {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ public class TableMetaDataContext {
|
|||
if (generatedKeyNames.length > 0) {
|
||||
this.generatedKeyColumnsUsed = true;
|
||||
}
|
||||
if (declaredColumns.size() > 0) {
|
||||
if (!declaredColumns.isEmpty()) {
|
||||
return new ArrayList<>(declaredColumns);
|
||||
}
|
||||
Set<String> keys = new LinkedHashSet<>(generatedKeyNames.length);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class GeneratedKeyHolder implements KeyHolder {
|
|||
@Override
|
||||
@Nullable
|
||||
public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException {
|
||||
if (this.keyList.size() == 0) {
|
||||
if (this.keyList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) {
|
||||
|
|
@ -89,7 +89,7 @@ public class GeneratedKeyHolder implements KeyHolder {
|
|||
@Override
|
||||
@Nullable
|
||||
public Map<String, Object> getKeys() throws InvalidDataAccessApiUsageException {
|
||||
if (this.keyList.size() == 0) {
|
||||
if (this.keyList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (this.keyList.size() > 1)
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ abstract class BootstrapUtils {
|
|||
@Nullable
|
||||
private static Class<?> resolveExplicitTestContextBootstrapper(Class<?> testClass) {
|
||||
Set<BootstrapWith> annotations = AnnotatedElementUtils.findAllMergedAnnotations(testClass, BootstrapWith.class);
|
||||
if (annotations.size() < 1) {
|
||||
if (annotations.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Assert.state(annotations.size() <= 1, () -> String.format(
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public abstract class ModelAndViewAssert {
|
|||
tempSet.addAll(incorrectSet);
|
||||
tempSet.removeAll(assertionSet);
|
||||
|
||||
if (tempSet.size() > 0) {
|
||||
if (!tempSet.isEmpty()) {
|
||||
sb.append("Set has too many elements:\n");
|
||||
for (Object element : tempSet) {
|
||||
sb.append('-');
|
||||
|
|
@ -214,7 +214,7 @@ public abstract class ModelAndViewAssert {
|
|||
tempSet.addAll(assertionSet);
|
||||
tempSet.removeAll(incorrectSet);
|
||||
|
||||
if (tempSet.size() > 0) {
|
||||
if (!tempSet.isEmpty()) {
|
||||
sb.append("Set is missing elements:\n");
|
||||
for (Object element : tempSet) {
|
||||
sb.append('-');
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class RegexPathElement extends PathElement {
|
|||
if (matches) {
|
||||
if (isNoMorePattern()) {
|
||||
if (matchingContext.determineRemainingPath &&
|
||||
((this.variableNames.size() == 0) ? true : textToMatch.length() > 0)) {
|
||||
(this.variableNames.isEmpty() ? true : textToMatch.length() > 0)) {
|
||||
matchingContext.remainingPathIndex = pathIndex + 1;
|
||||
matches = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class InitBinderBindingContext extends BindingContext {
|
|||
InitBinder ann = binderMethod.getMethodAnnotation(InitBinder.class);
|
||||
Assert.state(ann != null, "No InitBinder annotation");
|
||||
Collection<String> names = Arrays.asList(ann.value());
|
||||
return (names.size() == 0 || names.contains(dataBinder.getObjectName()));
|
||||
return (names.isEmpty() || names.contains(dataBinder.getObjectName()));
|
||||
})
|
||||
.forEach(method -> invokeBinderMethod(dataBinder, exchange, method));
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ public class TagWriter {
|
|||
}
|
||||
|
||||
private boolean inTag() {
|
||||
return this.tagState.size() > 0;
|
||||
return !this.tagState.isEmpty();
|
||||
}
|
||||
|
||||
private TagStateEntry currentState() {
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
|||
}
|
||||
ClassLoader classLoader = getApplicationContext().getClassLoader();
|
||||
Assert.state(classLoader != null, "No ClassLoader");
|
||||
return (urls.size() > 0 ? new URLClassLoader(urls.toArray(new URL[urls.size()]), classLoader) : classLoader);
|
||||
return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[urls.size()]), classLoader) : classLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue