Use RpcEffectiveStatement.input() 06/103406/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Nov 2022 07:54:00 +0000 (08:54 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Nov 2022 07:54:00 +0000 (08:54 +0100)
This saves a bit of code.

Change-Id: I77c482b6566fb4cb5102eae8ab84999f4d9ad083
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/ContentRoutedRpcContext.java

index 122b2d39611dc3a99e6456407fc319c32fbea6c9..c240230b39460598c00332d27731b398bc51770b 100644 (file)
@@ -14,7 +14,6 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.odlext.model.api.ContextReferenceEffectiveStatement;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
@@ -39,10 +38,7 @@ public record ContentRoutedRpcContext(@NonNull QName identity, @NonNull QName le
      * @return A {@link ContentRoutedRpcContext}, or {@code null} if the RPC does not contain context information
      */
     public static @Nullable ContentRoutedRpcContext forRpc(final RpcEffectiveStatement rpc) {
-        final var input = rpc.findFirstEffectiveSubstatement(InputEffectiveStatement.class)
-            .orElseThrow(() -> new IllegalArgumentException("Cannot find input in " + rpc));
-
-        for (var stmt : input.effectiveSubstatements()) {
+        for (var stmt : rpc.input().effectiveSubstatements()) {
             // TODO: LeafEffectiveStatement instead? Because that is what we are promising for #leaf()'s QName
             if (stmt instanceof SchemaTreeEffectiveStatement<?> schemaStmt) {
                 final var context =
@@ -52,7 +48,6 @@ public record ContentRoutedRpcContext(@NonNull QName identity, @NonNull QName le
                 }
             }
         }
-
         return null;
     }
 }