Use switch expression where feasible

This commit is contained in:
Yanming Zhou
2023-11-01 10:49:43 +08:00
committed by Sam Brannen
parent 8ed04b5dd1
commit 490b5c77fc
28 changed files with 420 additions and 424 deletions

View File

@@ -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();

View File

@@ -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--;