@Test public void testToString() throws Exception { assertEquals("127.0.0.1", NodeIdConv.toString(node1)); assertEquals("0.0.0.1", NodeIdConv.toString(node2)); assertEquals("127.124.56.1", NodeIdConv.toString(node3)); List<Peer> peerList = new ArrayList<>(); PeerSequenceBuilder peerSequenceBuilder = new PeerSequenceBuilder(); peerSequenceBuilder.setPeer(peerList); PeerBuilder peerBuilder = new PeerBuilder(); peerBuilder.setNodeId(node1); peerBuilder.setSeq(0); peerList.add(peerBuilder.build()); peerBuilder = new PeerBuilder(); peerBuilder.setNodeId(node2); peerBuilder.setSeq(1); peerList.add(peerBuilder.build()); assertEquals("127.0.0.1,0.0.0.1", NodeIdConv.toString(peerSequenceBuilder.build())); NodeId nullNodeId = null; assertEquals("", NodeIdConv.toString(nullNodeId)); }
private static String toString(List<NodeId> nodeIds) { StringBuilder result = new StringBuilder(); if (nodeIds != null) { for (NodeId nodeId : nodeIds) { result.append(toString(nodeId)).append(" "); } } return result.toString().trim().replaceAll(" ", ","); }
NodeIdConv { private static String toString(List<NodeId> nodeIds) { StringBuilder result = new StringBuilder(); if (nodeIds != null) { for (NodeId nodeId : nodeIds) { result.append(toString(nodeId)).append(" "); } } return result.toString().trim().replaceAll(" ", ","); } }
NodeIdConv { private static String toString(List<NodeId> nodeIds) { StringBuilder result = new StringBuilder(); if (nodeIds != null) { for (NodeId nodeId : nodeIds) { result.append(toString(nodeId)).append(" "); } } return result.toString().trim().replaceAll(" ", ","); } private  NodeIdConv(); }
NodeIdConv { private static String toString(List<NodeId> nodeIds) { StringBuilder result = new StringBuilder(); if (nodeIds != null) { for (NodeId nodeId : nodeIds) { result.append(toString(nodeId)).append(" "); } } return result.toString().trim().replaceAll(" ", ","); } private  NodeIdConv(); static NodeId _decode(byte[] array); static NodeId create(int nodeId); static NodeId createNodeId(InetAddress inetAddress); static NodeId createNodeId(String prefix); static PeerSequence createPeerSequence(List<NodeId> nodeIds); static List<NodeId> decode(byte[] array); static boolean equalTo(NodeId nodeId1, NodeId nodeId2); static List<NodeId> getPeerSequence(PeerSequence peerSequence); static byte[] toBytes(List<NodeId> nodesIds); static byte[] toBytes(NodeId nodeId); static String toString(NodeId nodeId); static String toString(PeerSequence peerSequence); }
NodeIdConv { private static String toString(List<NodeId> nodeIds) { StringBuilder result = new StringBuilder(); if (nodeIds != null) { for (NodeId nodeId : nodeIds) { result.append(toString(nodeId)).append(" "); } } return result.toString().trim().replaceAll(" ", ","); } private  NodeIdConv(); static NodeId _decode(byte[] array); static NodeId create(int nodeId); static NodeId createNodeId(InetAddress inetAddress); static NodeId createNodeId(String prefix); static PeerSequence createPeerSequence(List<NodeId> nodeIds); static List<NodeId> decode(byte[] array); static boolean equalTo(NodeId nodeId1, NodeId nodeId2); static List<NodeId> getPeerSequence(PeerSequence peerSequence); static byte[] toBytes(List<NodeId> nodesIds); static byte[] toBytes(NodeId nodeId); static String toString(NodeId nodeId); static String toString(PeerSequence peerSequence);  }