BUG-2383: Make TableContext.clearTable() reusable 16/16216/2
authorRobert Varga <rovarga@cisco.com>
Mon, 9 Mar 2015 17:39:47 +0000 (18:39 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 9 Mar 2015 19:36:23 +0000 (20:36 +0100)
An input table context is bound to a table. Refactor clearTable() to be
usable from other contexts, too.

Change-Id: Ic91326bf9f931f8dc1298ba67439253dece50e4c
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/TableContext.java

index 26414299bd09b76049a6dd0e01b5e9b6c70751ec..2993b9174022da694b56e5b1d54b137b5c974543 100644 (file)
@@ -95,17 +95,21 @@ final class TableContext {
         return tableId;
     }
 
-    void clearTable(final DOMDataWriteTransaction tx) {
+    static void clearTable(final DOMDataWriteTransaction tx, final RIBSupport tableSupport, final YangInstanceIdentifier tableId) {
         final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb =
                 ImmutableNodes.mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates)tableId.getLastPathArgument()).withChild(EMPTY_TABLE_ATTRIBUTES);
 
         final ChoiceNode routes = tableSupport.emptyRoutes();
-        Verify.verifyNotNull(routes, "Null empty routes in %s", this);
+        Verify.verifyNotNull(routes, "Null empty routes in %s", tableSupport);
         Verify.verify(Routes.QNAME.equals(routes.getNodeType()), "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);
 
         tx.put(LogicalDatastoreType.OPERATIONAL, tableId, tb.withChild(routes).build());
     }
 
+    void clearTable(final DOMDataWriteTransaction tx) {
+        clearTable(tx, tableSupport, tableId);
+    }
+
     void removeTable(final DOMDataWriteTransaction tx) {
         tx.delete(LogicalDatastoreType.OPERATIONAL, tableId);
     }