@Test public void testLoopDetection() throws Exception { List<SxpBindingFields> bindings = new ArrayList<>(); List<Peer> peerList = new ArrayList<>(); List<Peer> peerList_ = new ArrayList<>(); peerList.add(getPeer("127.0.0.0", 0)); peerList.add(getPeer("127.0.0.1", 1)); peerList.add(getPeer("127.0.0.2", 2)); peerList_.addAll(peerList); bindings.add(getBinding("5.5.5.5/32", 20, new PeerSequenceBuilder().setPeer(peerList).build())); peerList = new ArrayList<>(); peerList.add(getPeer("127.0.1.0", 0)); peerList.add(getPeer("127.0.2.1", 1)); peerList.add(getPeer("127.0.3.2", 2)); bindings.add(getBinding("15.15.15.15/32", 10, new PeerSequenceBuilder().setPeer(peerList).build())); List<SxpBindingFields> bindings_ = BindingHandler.loopDetection(new NodeId("127.0.2.1"), bindings.stream()).collect(Collectors.toList()); assertNotNull(bindings); assertEquals(1, bindings_.size()); assertEquals("5.5.5.5/32", IpPrefixConv.toString(bindings_.get(0).getIpPrefix())); Stream<SxpBindingFields> result = BindingHandler.loopDetection(null, bindings.stream()); assertEquals(result.count(), bindings.size()); Stream<SxpBindingFields> result2 = BindingHandler.loopDetection(new NodeId("127.0.2.1"), null); assertEquals(result2, null); }
public static <T extends SxpBindingFields> Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings) { if (nodeId != null && bindings != null) { return bindings.filter(b -> !NodeIdConv.getPeerSequence(b.getPeerSequence()).contains(nodeId)); } return bindings; }
BindingHandler { public static <T extends SxpBindingFields> Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings) { if (nodeId != null && bindings != null) { return bindings.filter(b -> !NodeIdConv.getPeerSequence(b.getPeerSequence()).contains(nodeId)); } return bindings; } }
BindingHandler { public static <T extends SxpBindingFields> Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings) { if (nodeId != null && bindings != null) { return bindings.filter(b -> !NodeIdConv.getPeerSequence(b.getPeerSequence()).contains(nodeId)); } return bindings; } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); }
BindingHandler { public static <T extends SxpBindingFields> Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings) { if (nodeId != null && bindings != null) { return bindings.filter(b -> !NodeIdConv.getPeerSequence(b.getPeerSequence()).contains(nodeId)); } return bindings; } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); void setBufferLimit(int limit); static Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter,
            NodeId nodeIdRemote); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessage message, SxpBindingFilter filter); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessageLegacy message); ListenableFuture<Void> processPurgeAllMessage(final SxpConnection connection); void processUpdate(final List<T> databaseDelete, final List<T> databaseAdd,
            final SxpConnection connection); }
BindingHandler { public static <T extends SxpBindingFields> Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings) { if (nodeId != null && bindings != null) { return bindings.filter(b -> !NodeIdConv.getPeerSequence(b.getPeerSequence()).contains(nodeId)); } return bindings; } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); void setBufferLimit(int limit); static Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter,
            NodeId nodeIdRemote); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessage message, SxpBindingFilter filter); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessageLegacy message); ListenableFuture<Void> processPurgeAllMessage(final SxpConnection connection); void processUpdate(final List<T> databaseDelete, final List<T> databaseAdd,
            final SxpConnection connection);  }