BUG-2383: Make TableContext.clearTable() reusable
[bgpcep.git] / 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);
     }