@@ -45,16 +45,17 @@ private static void handleKey(Map<?, ?> map, String key, List<Object> values) {
45
45
46
46
private static void handleValues (List <Object > values , String name , List <Object > newValues ) throws ReflectiveOperationException {
47
47
for (Object value : values )
48
- if (value == null )
49
- newValues .add (null );
50
- else if (value instanceof Map m )
51
- handleKey (m , name , newValues );
52
- else {
53
- try {
48
+ switch (value ) {
49
+ case null -> newValues .add (null );
50
+ case Map <?, ?> m -> handleKey (m , name , newValues );
51
+ default -> {
54
52
if (value instanceof Object [] || value instanceof List )
55
- handleIndex (value , Integer .parseInt (name ), newValues );
56
- } catch (NumberFormatException unused ) {}
57
- handleField (value , name , newValues );
53
+ try {
54
+ handleIndex (value , Integer .parseInt (name ), newValues );
55
+ return ;
56
+ } catch (NumberFormatException unused ) {}
57
+ handleField (value , name , newValues );
58
+ }
58
59
}
59
60
}
60
61
@@ -68,50 +69,50 @@ public boolean check(Object root, String rootFieldExpression, HashSet<String> pa
68
69
fullName += name ;
69
70
if (fullName .equals ("*" ))
70
71
for (Object o : values )
71
- if (o == null )
72
- newValues .add (null );
73
- else if (o instanceof Object [] a )
74
- for (Object item : a )
75
- newValues .add (item );
76
- else if (o instanceof Iterable e )
77
- for (Object item : e )
78
- newValues .add (item );
79
- else
80
- throw new RuntimeException ("Unsupported type for iteration: " + o .getClass ());
72
+ switch (o ) {
73
+ case null -> newValues .add (null );
74
+ case Object [] a -> {
75
+ for (Object item : a )
76
+ newValues .add (item );
77
+ }
78
+ case Iterable <?> e -> {
79
+ for (Object item : e )
80
+ newValues .add (item );
81
+ }
82
+ default -> throw new RuntimeException ("Unsupported type for iteration: " + o .getClass ());
83
+ }
81
84
else if (name .length () >= 3 && name .substring (name .length () - 3 , name .length () - 1 ).equals ("//" ))
82
85
fullName = fullName .substring (0 , fullName .length () - 3 ) + fullName .substring (fullName .length () - 2 );
83
86
else if (name .length () >= 2 && name .charAt (name .length () - 2 ) == '/' ) {
84
87
fullName = fullName .substring (0 , fullName .length () - 2 );
85
88
switch (Character .toUpperCase (name .charAt (name .length () - 1 ))) {
86
- case 'C' :
89
+ case 'C' -> {
87
90
fullName += "." ;
88
91
continue ;
89
- case 'F' :
92
+ }
93
+ case 'F' -> {
90
94
for (Object o : values )
91
95
if (o == null )
92
96
newValues .add (null );
93
97
else
94
98
handleField (o , fullName , newValues );
95
- break ;
96
- case 'I' :
99
+ }
100
+ case 'I' -> {
97
101
for (Object o : values )
98
102
if (o == null )
99
103
newValues .add (null );
100
104
else
101
105
handleIndex (o , Integer .parseInt (fullName ), newValues );
102
- break ;
103
- case 'K' :
106
+ }
107
+ case 'K' -> {
104
108
for (Object o : values )
105
109
if (o == null )
106
110
newValues .add (null );
107
111
else
108
112
handleKey ((Map <?, ?>)o , fullName , newValues );
109
- break ;
110
- case '*' :
111
- handleValues (values , fullName + "*" , newValues );
112
- break ;
113
- default :
114
- throw new RuntimeException ("Unsupported suffix: " + name .charAt (name .length () - 1 ));
113
+ }
114
+ case '*' -> handleValues (values , fullName + "*" , newValues );
115
+ default -> throw new RuntimeException ("Unsupported suffix: " + name .charAt (name .length () - 1 ));
115
116
}
116
117
} else
117
118
handleValues (values , fullName , newValues );
0 commit comments