@Test public void testParsePath() { Object[] tv = { "M / 44H / 0H / 0H / 1 / 1", ImmutableList.of(new ChildNumber(44, true), new ChildNumber(0, true), new ChildNumber(0, true), new ChildNumber(1, false), new ChildNumber(1, false)), false, "M/7H/3/3/1H/", ImmutableList.of(new ChildNumber(7, true), new ChildNumber(3, false), new ChildNumber(3, false), new ChildNumber(1, true)), false, "m/7H/3/3/1H/", ImmutableList.of(new ChildNumber(7, true), new ChildNumber(3, false), new ChildNumber(3, false), new ChildNumber(1, true)), true, "1 H / 2 H / 3 H /", ImmutableList.of(new ChildNumber(1, true), new ChildNumber(2, true), new ChildNumber(3, true)), false, "1 / 2 / 3 /", ImmutableList.of(new ChildNumber(1, false), new ChildNumber(2, false), new ChildNumber(3, false)), false }; for (int i = 0; i < tv.length; i += 3) { String strPath = (String) tv[i]; List<ChildNumber> expectedPath = (List<ChildNumber>) tv[i + 1]; boolean expectedHasPrivateKey = (Boolean) tv[i + 2]; HDPath path = HDPath.parsePath(strPath); Assert.assertEquals(path, expectedPath); Assert.assertEquals(path.hasPrivateKey, expectedHasPrivateKey); } }
public static HDPath parsePath(@Nonnull String path) { List<String> parsedNodes = new LinkedList<>(SEPARATOR_SPLITTER.splitToList(path)); boolean hasPrivateKey = false; if (!parsedNodes.isEmpty()) { final String firstNode = parsedNodes.get(0); if (firstNode.equals(Character.toString(PREFIX_PRIVATE))) hasPrivateKey = true; if (hasPrivateKey || firstNode.equals(Character.toString(PREFIX_PUBLIC))) parsedNodes.remove(0); } List<ChildNumber> nodes = new ArrayList<>(parsedNodes.size()); for (String n : parsedNodes) { if (n.isEmpty()) continue; boolean isHard = n.endsWith("H"); if (isHard) n = n.substring(0, n.length() - 1).trim(); int nodeNumber = Integer.parseInt(n); nodes.add(new ChildNumber(nodeNumber, isHard)); } return new HDPath(hasPrivateKey, nodes); }
HDPath extends AbstractList<ChildNumber> { public static HDPath parsePath(@Nonnull String path) { List<String> parsedNodes = new LinkedList<>(SEPARATOR_SPLITTER.splitToList(path)); boolean hasPrivateKey = false; if (!parsedNodes.isEmpty()) { final String firstNode = parsedNodes.get(0); if (firstNode.equals(Character.toString(PREFIX_PRIVATE))) hasPrivateKey = true; if (hasPrivateKey || firstNode.equals(Character.toString(PREFIX_PUBLIC))) parsedNodes.remove(0); } List<ChildNumber> nodes = new ArrayList<>(parsedNodes.size()); for (String n : parsedNodes) { if (n.isEmpty()) continue; boolean isHard = n.endsWith("H"); if (isHard) n = n.substring(0, n.length() - 1).trim(); int nodeNumber = Integer.parseInt(n); nodes.add(new ChildNumber(nodeNumber, isHard)); } return new HDPath(hasPrivateKey, nodes); } }
HDPath extends AbstractList<ChildNumber> { public static HDPath parsePath(@Nonnull String path) { List<String> parsedNodes = new LinkedList<>(SEPARATOR_SPLITTER.splitToList(path)); boolean hasPrivateKey = false; if (!parsedNodes.isEmpty()) { final String firstNode = parsedNodes.get(0); if (firstNode.equals(Character.toString(PREFIX_PRIVATE))) hasPrivateKey = true; if (hasPrivateKey || firstNode.equals(Character.toString(PREFIX_PUBLIC))) parsedNodes.remove(0); } List<ChildNumber> nodes = new ArrayList<>(parsedNodes.size()); for (String n : parsedNodes) { if (n.isEmpty()) continue; boolean isHard = n.endsWith("H"); if (isHard) n = n.substring(0, n.length() - 1).trim(); int nodeNumber = Integer.parseInt(n); nodes.add(new ChildNumber(nodeNumber, isHard)); } return new HDPath(hasPrivateKey, nodes); } HDPath(boolean hasPrivateKey, List<ChildNumber> list);  HDPath(List<ChildNumber> list); }
HDPath extends AbstractList<ChildNumber> { public static HDPath parsePath(@Nonnull String path) { List<String> parsedNodes = new LinkedList<>(SEPARATOR_SPLITTER.splitToList(path)); boolean hasPrivateKey = false; if (!parsedNodes.isEmpty()) { final String firstNode = parsedNodes.get(0); if (firstNode.equals(Character.toString(PREFIX_PRIVATE))) hasPrivateKey = true; if (hasPrivateKey || firstNode.equals(Character.toString(PREFIX_PUBLIC))) parsedNodes.remove(0); } List<ChildNumber> nodes = new ArrayList<>(parsedNodes.size()); for (String n : parsedNodes) { if (n.isEmpty()) continue; boolean isHard = n.endsWith("H"); if (isHard) n = n.substring(0, n.length() - 1).trim(); int nodeNumber = Integer.parseInt(n); nodes.add(new ChildNumber(nodeNumber, isHard)); } return new HDPath(hasPrivateKey, nodes); } HDPath(boolean hasPrivateKey, List<ChildNumber> list);  HDPath(List<ChildNumber> list); static HDPath M(List<ChildNumber> list); static HDPath M(); static HDPath M(ChildNumber childNumber); static HDPath M(ChildNumber... children); static HDPath m(List<ChildNumber> list); static HDPath m(); static HDPath m(ChildNumber childNumber); static HDPath m(ChildNumber... children); static HDPath parsePath(@Nonnull String path); boolean hasPrivateKey(); HDPath extend(ChildNumber child1, ChildNumber... children); HDPath extend(HDPath path2); HDPath extend(List<ChildNumber> path2); @Override ChildNumber get(int index); @Override int size(); @Override String toString(); }
HDPath extends AbstractList<ChildNumber> { public static HDPath parsePath(@Nonnull String path) { List<String> parsedNodes = new LinkedList<>(SEPARATOR_SPLITTER.splitToList(path)); boolean hasPrivateKey = false; if (!parsedNodes.isEmpty()) { final String firstNode = parsedNodes.get(0); if (firstNode.equals(Character.toString(PREFIX_PRIVATE))) hasPrivateKey = true; if (hasPrivateKey || firstNode.equals(Character.toString(PREFIX_PUBLIC))) parsedNodes.remove(0); } List<ChildNumber> nodes = new ArrayList<>(parsedNodes.size()); for (String n : parsedNodes) { if (n.isEmpty()) continue; boolean isHard = n.endsWith("H"); if (isHard) n = n.substring(0, n.length() - 1).trim(); int nodeNumber = Integer.parseInt(n); nodes.add(new ChildNumber(nodeNumber, isHard)); } return new HDPath(hasPrivateKey, nodes); } HDPath(boolean hasPrivateKey, List<ChildNumber> list);  HDPath(List<ChildNumber> list); static HDPath M(List<ChildNumber> list); static HDPath M(); static HDPath M(ChildNumber childNumber); static HDPath M(ChildNumber... children); static HDPath m(List<ChildNumber> list); static HDPath m(); static HDPath m(ChildNumber childNumber); static HDPath m(ChildNumber... children); static HDPath parsePath(@Nonnull String path); boolean hasPrivateKey(); HDPath extend(ChildNumber child1, ChildNumber... children); HDPath extend(HDPath path2); HDPath extend(List<ChildNumber> path2); @Override ChildNumber get(int index); @Override int size(); @Override String toString();  }