@Test public void testFullPath() throws IOException { String filepath = "com/sandboni/core/engine/Application.java"; String fullPath = treeWalkResolver.getFullPath(filepath); assertNotNull(fullPath); assertEquals("engine/src/main/java/com/sandboni/core/engine/Application.java", fullPath); }
public String getFullPath(String packageName) throws IOException { List<Map.Entry<String, String>> tree = getCommitTree(); String reversed = new StringBuilder(packageName).reverse().toString(); int index = Collections.binarySearch(tree, new AbstractMap.SimpleEntry<>(reversed, packageName), (o1, o2) -> o1.getKey().startsWith(o2.getKey()) ? 0 : o1.getKey().compareTo(o2.getKey())); return index >= 0 ? tree.get(index).getValue() : null; }
TreeWalkResolver { public String getFullPath(String packageName) throws IOException { List<Map.Entry<String, String>> tree = getCommitTree(); String reversed = new StringBuilder(packageName).reverse().toString(); int index = Collections.binarySearch(tree, new AbstractMap.SimpleEntry<>(reversed, packageName), (o1, o2) -> o1.getKey().startsWith(o2.getKey()) ? 0 : o1.getKey().compareTo(o2.getKey())); return index >= 0 ? tree.get(index).getValue() : null; } }
TreeWalkResolver { public String getFullPath(String packageName) throws IOException { List<Map.Entry<String, String>> tree = getCommitTree(); String reversed = new StringBuilder(packageName).reverse().toString(); int index = Collections.binarySearch(tree, new AbstractMap.SimpleEntry<>(reversed, packageName), (o1, o2) -> o1.getKey().startsWith(o2.getKey()) ? 0 : o1.getKey().compareTo(o2.getKey())); return index >= 0 ? tree.get(index).getValue() : null; } TreeWalkResolver(Repository repository, String commitId); }
TreeWalkResolver { public String getFullPath(String packageName) throws IOException { List<Map.Entry<String, String>> tree = getCommitTree(); String reversed = new StringBuilder(packageName).reverse().toString(); int index = Collections.binarySearch(tree, new AbstractMap.SimpleEntry<>(reversed, packageName), (o1, o2) -> o1.getKey().startsWith(o2.getKey()) ? 0 : o1.getKey().compareTo(o2.getKey())); return index >= 0 ? tree.get(index).getValue() : null; } TreeWalkResolver(Repository repository, String commitId); String getFullPath(String packageName); }
TreeWalkResolver { public String getFullPath(String packageName) throws IOException { List<Map.Entry<String, String>> tree = getCommitTree(); String reversed = new StringBuilder(packageName).reverse().toString(); int index = Collections.binarySearch(tree, new AbstractMap.SimpleEntry<>(reversed, packageName), (o1, o2) -> o1.getKey().startsWith(o2.getKey()) ? 0 : o1.getKey().compareTo(o2.getKey())); return index >= 0 ? tree.get(index).getValue() : null; } TreeWalkResolver(Repository repository, String commitId); String getFullPath(String packageName);  }