/** * Construct a path from an absolute component path hierarchy. * * <p>For the root path, use {@link Path#root()}. * * @param firstPath Path of the first sub-component. * @param paths Additional path components. */ public static Path absolute(String firstPath, String... paths) { ImmutableList.Builder<String> builder = ImmutableList.builder(); validatePathElement(firstPath); builder.add(firstPath); for (String path : paths) { validatePathElement(path); builder.add(path); } return new Path(builder.build()); }
/** Path for display data registered by a top-level component. */ public static Path root() { return new Path(ImmutableList.of()); }
/** * Extend the path by appending a sub-component path. The new path element is added to the end * of the path hierarchy. * * <p>Returns a new {@link Path} instance; the originating {@link Path} is not modified. */ public Path extend(String path) { validatePathElement(path); return new Path( ImmutableList.<String>builder().addAll(components.iterator()).add(path).build()); }