/** Factory method to produce instance of NetconfOperationRouter */
  public static NetconfOperationRouter createOperationRouter(
      NetconfOperationServiceSnapshot netconfOperationServiceSnapshot,
      CapabilityProvider capabilityProvider,
      DefaultCommitNotificationProducer commitNotifier) {
    NetconfOperationRouterImpl router =
        new NetconfOperationRouterImpl(netconfOperationServiceSnapshot);

    Preconditions.checkNotNull(netconfOperationServiceSnapshot);
    Preconditions.checkNotNull(capabilityProvider);

    final String sessionId = netconfOperationServiceSnapshot.getNetconfSessionIdForReporting();

    final Set<NetconfOperation> defaultNetconfOperations = Sets.newHashSet();
    defaultNetconfOperations.add(new DefaultGetSchema(capabilityProvider, sessionId));
    defaultNetconfOperations.add(new DefaultCloseSession(sessionId, router));
    defaultNetconfOperations.add(new DefaultStartExi(sessionId));
    defaultNetconfOperations.add(new DefaultStopExi(sessionId));
    defaultNetconfOperations.add(
        new DefaultCommit(commitNotifier, capabilityProvider, sessionId, router));

    router.initNetconfOperations(
        getAllNetconfOperations(defaultNetconfOperations, netconfOperationServiceSnapshot));

    return router;
  }
  private static Set<NetconfOperation> getAllNetconfOperations(
      Set<NetconfOperation> defaultNetconfOperations,
      NetconfOperationServiceSnapshot netconfOperationServiceSnapshot) {
    Set<NetconfOperation> result = new HashSet<>();
    result.addAll(defaultNetconfOperations);

    for (NetconfOperationService netconfOperationService :
        netconfOperationServiceSnapshot.getServices()) {
      final Set<NetconfOperation> netOpsFromService =
          netconfOperationService.getNetconfOperations();
      for (NetconfOperation netconfOperation : netOpsFromService) {
        Preconditions.checkState(
            result.contains(netconfOperation) == false,
            "Netconf operation %s already present",
            netconfOperation);
        result.add(netconfOperation);
      }
    }
    return Collections.unmodifiableSet(result);
  }
 @Override
 public void close() {
   netconfOperationServiceSnapshot.close();
 }