Modernize code for diamond, isEmpty & pattern matching

This commit is contained in:
Tran Ngoc Nhan
2024-09-24 01:42:38 +07:00
committed by GitHub
parent 40faaa0c15
commit fc377126de
107 changed files with 550 additions and 454 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@@ -37,6 +37,7 @@ import org.springframework.util.xml.DomUtils;
/**
* @author David Turanski
* @author Artem Bilan
* @author Ngoc Nhan
*
*/
public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionParser {
@@ -63,7 +64,7 @@ public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionP
List<Element> variableElements = DomUtils.getChildElementsByTagName(element, "variable");
String scriptVariableGeneratorName = element.getAttribute("script-variable-generator");
if (StringUtils.hasText(scriptVariableGeneratorName) && variableElements.size() > 0) {
if (StringUtils.hasText(scriptVariableGeneratorName) && !variableElements.isEmpty()) {
parserContext.getReaderContext().error(
"'script-variable-generator' and 'variable' sub-elements are mutually exclusive.", element);
return;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@@ -40,6 +40,7 @@ import org.springframework.util.Assert;
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
* @author Ngoc Nhan
*
* @since 2.1
*/
@@ -79,7 +80,7 @@ public abstract class AbstractScriptExecutor implements ScriptExecutor {
}
Bindings bindings = null;
if (variables != null && variables.size() > 0) {
if (variables != null && !variables.isEmpty()) {
bindings = new SimpleBindings(variables);
result = this.scriptEngine.eval(script, bindings);
}