/** * Returns an empty path which has a single name, the empty string. */ public JimfsPath emptyPath() { JimfsPath result = emptyPath; if (result == null) { // use createPathInternal to avoid recursive call from createPath() result = createPathInternal(null, ImmutableList.of(Name.EMPTY)); emptyPath = result; return result; } return result; }
/** * Returns a path with the given root (or no root, if null) and the given names. */ public JimfsPath createPath(@Nullable Name root, Iterable<Name> names) { ImmutableList<Name> nameList = ImmutableList.copyOf(Iterables.filter(names, NOT_EMPTY)); if (root == null && nameList.isEmpty()) { // ensure the canonical empty path (one empty string name) is used rather than a path with // no root and no names return emptyPath(); } return createPathInternal(root, nameList); }
/** * Resolves the given name against this path. The name is assumed not to be a root name. */ JimfsPath resolve(Name name) { if (name.toString().isEmpty()) { return this; } return pathService.createPathInternal( root, ImmutableList.<Name>builder() .addAll(names) .add(name) .build()); }
/** * Returns an empty path which has a single name, the empty string. */ public JimfsPath emptyPath() { JimfsPath result = emptyPath; if (result == null) { // use createPathInternal to avoid recursive call from createPath() result = createPathInternal(null, ImmutableList.of(Name.EMPTY)); emptyPath = result; return result; } return result; }
/** * Returns a path with the given root (or no root, if null) and the given names. */ public JimfsPath createPath(@Nullable Name root, Iterable<Name> names) { ImmutableList<Name> nameList = ImmutableList.copyOf(Iterables.filter(names, NOT_EMPTY)); if (root == null && nameList.isEmpty()) { // ensure the canonical empty path (one empty string name) is used rather than a path with // no root and no names return emptyPath(); } return createPathInternal(root, nameList); }
/** * Resolves the given name against this path. The name is assumed not to be a root name. */ JimfsPath resolve(Name name) { if (name.toString().isEmpty()) { return this; } return pathService.createPathInternal( root, ImmutableList.<Name>builder() .addAll(names) .add(name) .build()); }