Make AugmentationCodecPrototype generic
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / AugmentationCodecPrototype.java
index c91de7f70f2fe2cf123ac7f352e564353977570b..1b5ae222f661a6dbaa0cb1829635fdd329473c79 100644 (file)
@@ -11,31 +11,29 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ImmutableSet;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.dom.codec.impl.NodeCodecContext.CodecContextFactory;
 import org.opendaylight.mdsal.binding.runtime.api.AugmentRuntimeType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
-import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.NodeStep;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 
-final class AugmentationCodecPrototype extends DataContainerCodecPrototype<AugmentRuntimeType> {
+final class AugmentationCodecPrototype<T extends Augmentation<?>>
+        extends CommonDataObjectCodecPrototype<AugmentRuntimeType> {
     private final @NonNull ImmutableSet<NodeIdentifier> childArgs;
 
-    @SuppressWarnings("unchecked")
-    AugmentationCodecPrototype(final Class<?> cls, final QNameModule namespace, final AugmentRuntimeType type,
+    AugmentationCodecPrototype(final @NonNull Class<T> cls, final AugmentRuntimeType type,
             final CodecContextFactory factory, final ImmutableSet<NodeIdentifier> childArgs) {
-        super(Item.of((Class<? extends DataObject>) cls), namespace, type, factory);
+        super(new NodeStep<>(cls), type, factory);
         this.childArgs = requireNonNull(childArgs);
     }
 
     @Override
-    NodeIdentifier getYangArg() {
+    NodeIdentifier yangArg() {
         throw new UnsupportedOperationException("Augmentation does not have PathArgument address");
     }
 
     @Override
-    AugmentationNodeContext<?> createInstance() {
-        return new AugmentationNodeContext<>(this);
+    AugmentationCodecContext<?> createInstance() {
+        return new AugmentationCodecContext<>(this);
     }
 
     // Guaranteed to be non-empty