@Test public void containsTest() { Assert.assertTrue(new Path("/").contains(new Path("/a/b/c"))); Assert.assertTrue(new Path("/a").contains(new Path("/a/b/c"))); Assert.assertTrue(new Path("/a/b").contains(new Path("/a/b/c"))); Assert.assertTrue(new Path("/a/b/c").contains(new Path("/a/b/c"))); Assert.assertFalse(new Path("/a/b/c").contains(new Path("/a/b"))); Assert.assertFalse(new Path("/a/b/c").contains(new Path("/a"))); Assert.assertFalse(new Path("/a/b/c").contains(new Path("/"))); Assert.assertTrue(new Path("/a/b/c").popFront().contains(new Path("/b/c"))); Assert.assertTrue(new Path("/a/b/c").popFront().contains(new Path("/b/c/d"))); Assert.assertFalse(new Path("/a/b/c").contains(new Path("/b/c"))); Assert.assertFalse(new Path("/a/b/c").contains(new Path("/a/c/b"))); Assert.assertFalse(new Path("/a/b/c").popFront().contains(new Path("/a/b/c"))); Assert.assertTrue(new Path("/a/b/c").popFront().contains(new Path("/b/c"))); Assert.assertTrue(new Path("/a/b/c").popFront().contains(new Path("/b/c/d"))); }
public boolean contains(Path other) { if (this.size() > other.size()) { return false; } int i = this.start; int j = other.start; while (i < this.end) { if (!this.pieces[i].equals(other.pieces[j])) { return false; } i++; j++; } return true; }
Path implements Iterable<ChildKey>, Comparable<Path> { public boolean contains(Path other) { if (this.size() > other.size()) { return false; } int i = this.start; int j = other.start; while (i < this.end) { if (!this.pieces[i].equals(other.pieces[j])) { return false; } i++; j++; } return true; } }
Path implements Iterable<ChildKey>, Comparable<Path> { public boolean contains(Path other) { if (this.size() > other.size()) { return false; } int i = this.start; int j = other.start; while (i < this.end) { if (!this.pieces[i].equals(other.pieces[j])) { return false; } i++; j++; } return true; } Path(ChildKey... segments);  Path(List<String> segments);  Path(String pathString); private  Path(ChildKey[] pieces, int start, int end); }
Path implements Iterable<ChildKey>, Comparable<Path> { public boolean contains(Path other) { if (this.size() > other.size()) { return false; } int i = this.start; int j = other.start; while (i < this.end) { if (!this.pieces[i].equals(other.pieces[j])) { return false; } i++; j++; } return true; } Path(ChildKey... segments);  Path(List<String> segments);  Path(String pathString); private  Path(ChildKey[] pieces, int start, int end); static Path getRelative(Path from, Path to); static Path getEmptyPath(); Path child(Path path); Path child(ChildKey child); @Override String toString(); String wireFormat(); List<String> asList(); ChildKey getFront(); Path popFront(); Path getParent(); ChildKey getBack(); boolean isEmpty(); int size(); @Override Iterator<ChildKey> iterator(); boolean contains(Path other); @Override boolean equals(Object other); @Override int hashCode(); @Override int compareTo(Path other); }
Path implements Iterable<ChildKey>, Comparable<Path> { public boolean contains(Path other) { if (this.size() > other.size()) { return false; } int i = this.start; int j = other.start; while (i < this.end) { if (!this.pieces[i].equals(other.pieces[j])) { return false; } i++; j++; } return true; } Path(ChildKey... segments);  Path(List<String> segments);  Path(String pathString); private  Path(ChildKey[] pieces, int start, int end); static Path getRelative(Path from, Path to); static Path getEmptyPath(); Path child(Path path); Path child(ChildKey child); @Override String toString(); String wireFormat(); List<String> asList(); ChildKey getFront(); Path popFront(); Path getParent(); ChildKey getBack(); boolean isEmpty(); int size(); @Override Iterator<ChildKey> iterator(); boolean contains(Path other); @Override boolean equals(Object other); @Override int hashCode(); @Override int compareTo(Path other);  }