remove unnecessary cast
[neutron.git] / transcriber / src / main / java / org / opendaylight / neutron / transcriber / NeutronSFCPortChainInterface.java
index 4bba854d60e7d92563f99b78259cff0ce32ba15f..65f38f761640a6cdac038b43ab6655ff4adb16b8 100644 (file)
@@ -14,28 +14,27 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.neutron.spi.INeutronSFCPortChainCRUD;
 import org.opendaylight.neutron.spi.NeutronSFCPortChain;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParameters;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParametersBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParametersKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortChains;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChain;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChainBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChainKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Created by Anil Vishnoi (avishnoi@Brocade.com)
+ * Created by Anil Vishnoi (avishnoi@Brocade.com).
  */
 public final class NeutronSFCPortChainInterface
-        extends AbstractNeutronInterface<PortChain, PortChains, NeutronSFCPortChain>
+        extends AbstractNeutronInterface<PortChain, PortChains, PortChainKey, NeutronSFCPortChain>
         implements INeutronSFCPortChainCRUD {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSFCPortChainInterface.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NeutronSFCPortChainInterface.class);
 
     NeutronSFCPortChainInterface(DataBroker db) {
-        super(db);
+        super(PortChainBuilder.class, db);
     }
 
     @Override
@@ -43,26 +42,13 @@ public final class NeutronSFCPortChainInterface
         return dataObjects.getPortChain();
     }
 
-    @Override
-    protected InstanceIdentifier<PortChain> createInstanceIdentifier(PortChain portChain) {
-        return InstanceIdentifier.create(Neutron.class).child(PortChains.class).child(PortChain.class,
-                portChain.getKey());
-    }
-
-    @Override
-    protected InstanceIdentifier<PortChains> createInstanceIdentifier() {
-        return InstanceIdentifier.create(Neutron.class).child(PortChains.class);
-    }
-
     @Override
     protected PortChain toMd(NeutronSFCPortChain neutronPortChain) {
 
-        LOGGER.trace("toMd: REST SFC Port Chain data : {}", neutronPortChain);
+        LOG.trace("toMd: REST SFC Port Chain data : {}", neutronPortChain);
 
         PortChainBuilder result = new PortChainBuilder();
-        result.setUuid(new Uuid(neutronPortChain.getID()));
-        result.setName(neutronPortChain.getName());
-        result.setTenantId(toUuid(neutronPortChain.getTenantID()));
+        toMdBaseAttributes(neutronPortChain, result);
         if (neutronPortChain.getPortPairGroupsUUID() != null) {
             List<Uuid> portPairGroups = new ArrayList<>();
             for (String uuid : neutronPortChain.getPortPairGroupsUUID()) {
@@ -88,24 +74,15 @@ public final class NeutronSFCPortChainInterface
             }
             result.setChainParameters(chainParams);
         }
-        LOGGER.trace("toMd: Yang SFC Port Chain data : {}", result);
+        LOG.trace("toMd: Yang SFC Port Chain data : {}", result);
         return result.build();
     }
 
-    @Override
-    protected PortChain toMd(String uuid) {
-        final PortChainBuilder portChainBuilder = new PortChainBuilder();
-        portChainBuilder.setUuid(toUuid(uuid));
-        return portChainBuilder.build();
-    }
-
     @Override
     protected NeutronSFCPortChain fromMd(PortChain mdPortChain) {
-        LOGGER.trace("fromMd: Yang SFC Port Chain data : {}", mdPortChain);
+        LOG.trace("fromMd: Yang SFC Port Chain data : {}", mdPortChain);
         NeutronSFCPortChain result = new NeutronSFCPortChain();
-        result.setID(mdPortChain.getUuid().getValue());
-        result.setName(mdPortChain.getName());
-        result.setTenantID(mdPortChain.getTenantId());
+        fromMdBaseAttributes(mdPortChain, result);
         if (mdPortChain.getPortPairGroups() != null) {
             List<String> portPairGroups = new ArrayList<>();
             for (Uuid uuid : mdPortChain.getPortPairGroups()) {
@@ -127,7 +104,7 @@ public final class NeutronSFCPortChainInterface
             }
             result.setChainParameters(chainParams);
         }
-        LOGGER.trace("fromMd: REST SFC Port Chain data : {}", result);
+        LOG.trace("fromMd: REST SFC Port Chain data : {}", result);
         return result;
     }
 }