@Override public FileSystem getFileSystem() { return pathService.getFileSystem(); }
/** * Equivalent to {@link #getFileSystem()} but with a return type of {@code JimfsFileSystem}. * {@code getFileSystem()}'s return type is left as {@code FileSystem} to make testing paths * easier (as long as methods that access the file system in some way are not called, the file * system can be a fake file system instance). */ public JimfsFileSystem getJimfsFileSystem() { return (JimfsFileSystem) pathService.getFileSystem(); }
/** * Creates a hash code for the given path. */ public int hash(JimfsPath path) { int hash = 31; hash = 31 * hash + getFileSystem().hashCode(); final Name root = path.root(); final ImmutableList<Name> names = path.names(); if (equalityUsesCanonicalForm) { // use hash codes of names themselves, which are based on the canonical form hash = 31 * hash + (root == null ? 0 : root.hashCode()); for (Name name : names) { hash = 31 * hash + name.hashCode(); } } else { // use hash codes from toString() form of names hash = 31 * hash + (root == null ? 0 : root.toString().hashCode()); for (Name name : names) { hash = 31 * hash + name.toString().hashCode(); } } return hash; }
@Override public FileSystem getFileSystem() { return pathService.getFileSystem(); }
/** * Equivalent to {@link #getFileSystem()} but with a return type of {@code JimfsFileSystem}. * {@code getFileSystem()}'s return type is left as {@code FileSystem} to make testing paths * easier (as long as methods that access the file system in some way are not called, the file * system can be a fake file system instance). */ public JimfsFileSystem getJimfsFileSystem() { return (JimfsFileSystem) pathService.getFileSystem(); }
/** * Creates a hash code for the given path. */ public int hash(JimfsPath path) { int hash = 31; hash = 31 * hash + getFileSystem().hashCode(); final Name root = path.root(); final ImmutableList<Name> names = path.names(); if (equalityUsesCanonicalForm) { // use hash codes of names themselves, which are based on the canonical form hash = 31 * hash + (root == null ? 0 : root.hashCode()); for (Name name : names) { hash = 31 * hash + name.hashCode(); } } else { // use hash codes from toString() form of names hash = 31 * hash + (root == null ? 0 : root.toString().hashCode()); for (Name name : names) { hash = 31 * hash + name.toString().hashCode(); } } return hash; }