@Test public void equalStartIsTheStart() { assertTrue(path("/one/two").startsWith(path("/one"))); }
@Override public boolean startsWith(Path other) { if (isAbsolute() != other.isAbsolute()) { return false; } if (other.getNameCount() > getNameCount()) { return false; } for (int i = 0; i < other.getNameCount(); i++) { if (!getName(i).toString().equals(other.getName(i).toString())) { return false; } } return true; }
BoxPath implements Path { @Override public boolean startsWith(Path other) { if (isAbsolute() != other.isAbsolute()) { return false; } if (other.getNameCount() > getNameCount()) { return false; } for (int i = 0; i < other.getNameCount(); i++) { if (!getName(i).toString().equals(other.getName(i).toString())) { return false; } } return true; } }
BoxPath implements Path { @Override public boolean startsWith(Path other) { if (isAbsolute() != other.isAbsolute()) { return false; } if (other.getNameCount() > getNameCount()) { return false; } for (int i = 0; i < other.getNameCount(); i++) { if (!getName(i).toString().equals(other.getName(i).toString())) { return false; } } return true; } BoxPath(BoxFileSystem fileSystem, String path); }
BoxPath implements Path { @Override public boolean startsWith(Path other) { if (isAbsolute() != other.isAbsolute()) { return false; } if (other.getNameCount() > getNameCount()) { return false; } for (int i = 0; i < other.getNameCount(); i++) { if (!getName(i).toString().equals(other.getName(i).toString())) { return false; } } return true; } BoxPath(BoxFileSystem fileSystem, String path); FolderLike toFilderLike(); @Override FileSystem getFileSystem(); @Override boolean isAbsolute(); @Override BoxPath getRoot(); @Override Path getFileName(); @Override BoxPath getParent(); @Override int getNameCount(); @Override BoxPath getName(int index); @Override BoxPath subpath(int beginIndex, int endIndex); @Override boolean startsWith(Path other); @Override boolean startsWith(String other); @Override boolean endsWith(Path other); @Override boolean endsWith(String other); @Override BoxPath normalize(); @Override BoxPath resolve(Path other); @Override BoxPath resolve(String other); @Override BoxPath resolveSibling(Path other); @Override BoxPath resolveSibling(String other); @Override BoxPath relativize(Path other); @Override URI toUri(); @Override BoxPath toAbsolutePath(); @Override BoxPath toRealPath(LinkOption... options); @Override File toFile(); @Override WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers); @Override WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events); @Override Iterator<Path> iterator(); @Override int compareTo(Path other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
BoxPath implements Path { @Override public boolean startsWith(Path other) { if (isAbsolute() != other.isAbsolute()) { return false; } if (other.getNameCount() > getNameCount()) { return false; } for (int i = 0; i < other.getNameCount(); i++) { if (!getName(i).toString().equals(other.getName(i).toString())) { return false; } } return true; } BoxPath(BoxFileSystem fileSystem, String path); FolderLike toFilderLike(); @Override FileSystem getFileSystem(); @Override boolean isAbsolute(); @Override BoxPath getRoot(); @Override Path getFileName(); @Override BoxPath getParent(); @Override int getNameCount(); @Override BoxPath getName(int index); @Override BoxPath subpath(int beginIndex, int endIndex); @Override boolean startsWith(Path other); @Override boolean startsWith(String other); @Override boolean endsWith(Path other); @Override boolean endsWith(String other); @Override BoxPath normalize(); @Override BoxPath resolve(Path other); @Override BoxPath resolve(String other); @Override BoxPath resolveSibling(Path other); @Override BoxPath resolveSibling(String other); @Override BoxPath relativize(Path other); @Override URI toUri(); @Override BoxPath toAbsolutePath(); @Override BoxPath toRealPath(LinkOption... options); @Override File toFile(); @Override WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers); @Override WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events); @Override Iterator<Path> iterator(); @Override int compareTo(Path other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }