fix: Java 11 compatibility with instanceof pattern

This commit is contained in:
Ben Woo 2023-03-24 14:12:26 +08:00
parent e3e3c039c3
commit 433160f187
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8

View File

@ -107,8 +107,8 @@ public class MVSettings {
if (node.getComments().length > 0) {
tempConfig.addComment(node.getPath(), node.getComments());
}
if (node instanceof ValueNode valueNode) {
tempConfig.set(node.getPath(), get(valueNode));
if (node instanceof ValueNode) {
tempConfig.set(node.getPath(), get((ValueNode) node));
}
}
@ -144,7 +144,7 @@ public class MVSettings {
*/
public Object get(@NotNull String name) {
return nodes.findNode(name)
.map(node -> (node instanceof ValueNode valueNode) ? get(valueNode) : null)
.map(node -> (node instanceof ValueNode) ? get((ValueNode) node) : null)
.orElse(null);
}
@ -190,7 +190,7 @@ public class MVSettings {
*/
public boolean set(@NotNull String name, Object value) {
return nodes.findNode(name)
.map(node -> node instanceof ValueNode valueNode && set(valueNode, value))
.map(node -> node instanceof ValueNode && set((ValueNode) node, value))
.orElse(false);
}