Use switch expression where feasible
This commit is contained in:
committed by
Sam Brannen
parent
8ed04b5dd1
commit
490b5c77fc
@@ -55,30 +55,30 @@ public class DefaultListableBeanFactoryBenchmark {
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
|
||||
|
||||
switch (this.mode) {
|
||||
case "simple":
|
||||
break;
|
||||
case "dependencyCheck":
|
||||
case "simple" -> {
|
||||
}
|
||||
case "dependencyCheck" -> {
|
||||
rbd = new RootBeanDefinition(LifecycleBean.class);
|
||||
rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
|
||||
this.beanFactory.addBeanPostProcessor(new LifecycleBean.PostProcessor());
|
||||
break;
|
||||
case "constructor":
|
||||
}
|
||||
case "constructor" -> {
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue("juergen");
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue("99");
|
||||
break;
|
||||
case "constructorArgument":
|
||||
}
|
||||
case "constructorArgument" -> {
|
||||
rbd.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference("spouse"));
|
||||
this.beanFactory.registerBeanDefinition("test", rbd);
|
||||
this.beanFactory.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
|
||||
break;
|
||||
case "properties":
|
||||
}
|
||||
case "properties" -> {
|
||||
rbd.getPropertyValues().add("name", "juergen");
|
||||
rbd.getPropertyValues().add("age", "99");
|
||||
break;
|
||||
case "resolvedProperties":
|
||||
}
|
||||
case "resolvedProperties" -> {
|
||||
rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse"));
|
||||
this.beanFactory.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
rbd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
|
||||
this.beanFactory.registerBeanDefinition("test", rbd);
|
||||
|
||||
@@ -976,11 +976,11 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
int length = propertyName.length();
|
||||
for (int i = startIndex; i < length; i++) {
|
||||
switch (propertyName.charAt(i)) {
|
||||
case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
|
||||
case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR -> {
|
||||
// The property name contains opening prefix(es)...
|
||||
unclosedPrefixes++;
|
||||
break;
|
||||
case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
|
||||
}
|
||||
case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR -> {
|
||||
if (unclosedPrefixes == 0) {
|
||||
// No unclosed prefix(es) in the property name (left) ->
|
||||
// this is the suffix we are looking for.
|
||||
@@ -991,13 +991,12 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
// just one that occurred within the property name.
|
||||
unclosedPrefixes--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String className = getClass().getName();
|
||||
|
||||
@@ -91,14 +91,14 @@ public abstract class PropertyAccessorUtils {
|
||||
int i = (last ? length - 1 : 0);
|
||||
while (last ? i >= 0 : i < length) {
|
||||
switch (propertyPath.charAt(i)) {
|
||||
case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
|
||||
case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
|
||||
case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR, PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR -> {
|
||||
inKey = !inKey;
|
||||
break;
|
||||
case PropertyAccessor.NESTED_PROPERTY_SEPARATOR_CHAR:
|
||||
}
|
||||
case PropertyAccessor.NESTED_PROPERTY_SEPARATOR_CHAR -> {
|
||||
if (!inKey) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (last) {
|
||||
i--;
|
||||
|
||||
Reference in New Issue
Block a user