Connect ContextReferenceExtractor with BindingMapping 34/103334/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 23 Nov 2022 15:58:02 +0000 (16:58 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 24 Nov 2022 14:35:58 +0000 (15:35 +0100)
The "getValue" magic string is well documented, make sure to reference
it in its BindingMapping form.

Change-Id: If152de3145f6821a6b83715a3232da8092ff6d73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/ContextReferenceExtractor.java

index 3eab1ced7f6d8b5ded5c2acf09cccd2c22e7f33d..446005642b2fec4239f07edff98a682847a647df 100644 (file)
@@ -14,6 +14,7 @@ import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.reflect.Method;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
@@ -79,9 +80,6 @@ abstract sealed class ContextReferenceExtractor {
     }
 
     private static final Logger LOG = LoggerFactory.getLogger(ContextReferenceExtractor.class);
-    // FIXME: this should be somewhere in BindingMapping or similar -- it works with ScalarTypeObject after all, which
-    //        is not obvious here
-    private static final String GET_VALUE_NAME = "getValue";
 
     static @Nullable ContextReferenceExtractor of(final Class<?> type) {
         final var contextGetter = getContextGetter(type);
@@ -120,7 +118,7 @@ abstract sealed class ContextReferenceExtractor {
     private static @Nullable Method findGetValueMethod(final Class<?> type, final Class<?> returnType) {
         final Method method;
         try {
-            method = type.getMethod(GET_VALUE_NAME);
+            method = type.getMethod(BindingMapping.SCALAR_TYPE_OBJECT_GET_VALUE_NAME);
         } catch (NoSuchMethodException e) {
             LOG.warn("Value class {} does not comform to Binding Specification v1.", type, e);
             return null;