@Test public void testNetTree1() throws Exception { List<String> ips = Arrays.asList("192.168.0.1", "192.168.0.2"); NetworkOrganizer.VirtualTree tree = new NetworkOrganizer.VirtualTree(); for (String ip : ips) tree.map(NetworkOrganizer.convertIpToOctets(ip)); assertEquals(2, tree.getUniqueBranches()); assertEquals(2, tree.getTotalBranches()); log.info("rewind: {}", tree.getHottestNetwork()); }
protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); String getMatchingAddress(); List<String> getSubset(int numShards); List<String> getSubset(int numShards, Collection<String> primary); }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); String getMatchingAddress(); List<String> getSubset(int numShards); List<String> getSubset(int numShards, Collection<String> primary);  }