Do not use BindingReflections to acquire augmentations 98/99998/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 7 Mar 2022 17:38:37 +0000 (18:38 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 7 Mar 2022 21:09:03 +0000 (22:09 +0100)
Augmentable interface exposes augmentations directly, hence we
can use it directly, without relying on reflection.

Change-Id: I21b86d581ff0a61db3975cf7655157e4e6678b1b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectStreamer.java
binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/BindingReflections.java

index 1a0793428747de1ef865eb2f2e39168bbe6b73f3..96e346eab35a02601397d838aec46faacf8fcd0f 100644 (file)
@@ -14,10 +14,8 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingStreamEventWriter;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
@@ -58,9 +56,7 @@ public abstract class DataObjectStreamer<T extends DataObject> implements DataOb
 
     protected static final void streamAugmentations(final DataObjectSerializerRegistry registry,
             final BindingStreamEventWriter writer, final Augmentable<?> obj) throws IOException {
-        final Map<Class<? extends Augmentation<?>>, Augmentation<?>> augmentations =
-                BindingReflections.getAugmentations(obj);
-        for (final Entry<Class<? extends Augmentation<?>>, Augmentation<?>> aug : augmentations.entrySet()) {
+        for (final var aug : obj.augmentations().entrySet()) {
             emitAugmentation(aug.getKey(), aug.getValue(), writer, registry);
         }
     }
index 6695cb780b783f474b7efec9d3a59e55376c4a90..ef55504e52957f0e39a3dcbe4d70b6e4ecd67dbe 100644 (file)
@@ -599,19 +599,6 @@ public final class BindingReflections {
         }
     }
 
-    /**
-     * Extracts augmentation from Binding DTO field using reflection.
-     *
-     * @param input Instance of DataObject which is augmentable and may contain augmentation
-     * @return Map of augmentations if read was successful, otherwise empty map.
-     * @deprecated Use {@link Augmentable#augmentations()} instead.
-     */
-    @SuppressWarnings("unchecked")
-    @Deprecated(forRemoval = true)
-    public static Map<Class<? extends Augmentation<?>>, Augmentation<?>> getAugmentations(final Augmentable<?> input) {
-        return (Map) input.augmentations();
-    }
-
     /**
      * Determines if two augmentation classes or case classes represents same
      * data.