Remove BindingReflections.resolveRpc{In,Out}putClass() 21/103021/6
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 2 Nov 2022 14:50:44 +0000 (15:50 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 24 Nov 2022 17:59:14 +0000 (18:59 +0100)
These methods are not used anywhere, remove them.

JIRA: MDSAL-788
Change-Id: I3ab399500e28c4cc446ab24b55080c2d4aa8af60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/RpcMethodInvoker.java
binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/BindingReflections.java
binding/mdsal-binding-spec-util/src/test/java/org/opendaylight/mdsal/binding/spec/reflect/BindingReflectionsTest.java

index a66348e9465e065428b7b06a05b6427953763a5f..ffe6077659ebf00bdc2f1f7e6c28c3b7a7ade411 100644 (file)
@@ -14,7 +14,6 @@ import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.reflect.Method;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -32,9 +31,6 @@ final class RpcMethodInvoker {
     }
 
     static RpcMethodInvoker from(final Method method) {
-        BindingReflections.resolveRpcInputClass(method)
-            .orElseThrow(() -> new IllegalArgumentException("Method " + method + " does not have an input argument"));
-
         final MethodHandle methodHandle;
         try {
             methodHandle = MethodHandles.publicLookup().unreflect(method);
index 8c96c2435d599d020241a7cac0ce0bddebc99bd3..50d04b0d7b85d709aa1ff6f4ef84c91179942328 100644 (file)
@@ -21,7 +21,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.util.Optional;
 import java.util.ServiceLoader;
 import java.util.concurrent.TimeUnit;
@@ -123,44 +122,6 @@ public final class BindingReflections {
                 && possibleMethod.getParameterCount() <= 2;
     }
 
-    /**
-     * Extracts Output class for RPC method.
-     *
-     * @param targetMethod method to scan
-     * @return Optional.empty() if result type could not be get, or return type is Void.
-     * @deprecated This method is unused and scheduled for removal
-     */
-    @Deprecated(since = "10.0.4", forRemoval = true)
-    @SuppressWarnings("rawtypes")
-    public static Optional<Class<?>> resolveRpcOutputClass(final Method targetMethod) {
-        checkState(isRpcMethod(targetMethod), "Supplied method is not a RPC invocation method");
-        Type futureType = targetMethod.getGenericReturnType();
-        Type rpcResultType = ClassLoaderUtils.getFirstGenericParameter(futureType).orElse(null);
-        Type rpcResultArgument = ClassLoaderUtils.getFirstGenericParameter(rpcResultType).orElse(null);
-        if (rpcResultArgument instanceof Class cls && !Void.class.equals(rpcResultArgument)) {
-            return Optional.of(cls);
-        }
-        return Optional.empty();
-    }
-
-    /**
-     * Extracts input class for RPC method.
-     *
-     * @param targetMethod method to scan
-     * @return Optional.empty() if RPC has no input, RPC input type otherwise.
-     * @deprecated This method is unused and scheduled for removal
-     */
-    @Deprecated(since = "10.0.4", forRemoval = true)
-    @SuppressWarnings("rawtypes")
-    public static Optional<Class<? extends DataContainer>> resolveRpcInputClass(final Method targetMethod) {
-        for (Class clazz : targetMethod.getParameterTypes()) {
-            if (DataContainer.class.isAssignableFrom(clazz)) {
-                return Optional.of(clazz);
-            }
-        }
-        return Optional.empty();
-    }
-
     public static @NonNull QName getQName(final BaseIdentity identity) {
         return getContractQName(identity);
     }
index 037eb085c0d87f903b3334d936047067086fc96a..47d02ada2f113e69a7f6173bf4315a543f9f6496 100644 (file)
@@ -44,11 +44,6 @@ public class BindingReflectionsTest {
         assertTrue(BindingReflections.isRpcMethod(TestImplementation.class.getDeclaredMethod("rpcMethodTest")));
         assertEquals(TestImplementation.class, BindingReflections.findAugmentationTarget(TestImplementation.class));
 
-        assertEquals(Object.class, BindingReflections.resolveRpcOutputClass(
-                TestImplementation.class.getDeclaredMethod("rpcMethodTest")).get());
-        assertFalse(BindingReflections.resolveRpcOutputClass(
-                TestImplementation.class.getDeclaredMethod("rpcMethodTest2")).isPresent());
-
         assertEquals(QName.create("test", "test"), BindingReflections.getQName(TestIdentity.VALUE));
     }
 
@@ -68,11 +63,6 @@ public class BindingReflectionsTest {
             return null;
         }
 
-        @SuppressWarnings("static-method")
-        ListenableFuture<?> rpcMethodTest2() {
-            return null;
-        }
-
         @Override
         public Class<TestImplementation> implementedInterface() {
             return TestImplementation.class;