Class PathGroup

java.lang.Object
jdk.jpackage.internal.util.PathGroup

public final class PathGroup extends Object
Group of paths. Each path in the group is assigned a unique id.
  • Constructor Details

    • PathGroup

      public PathGroup(Map<Object,Path> paths)
      Creates path group with the initial paths.
      Parameters:
      paths - the initial paths
  • Method Details

    • getPath

      public Path getPath(Object id)
      Returns a path associated with the given identifier in this path group.
      Parameters:
      id - the identifier
      Returns:
      the path corresponding to the given identifier in this path group or null if there is no such path
    • setPath

      public void setPath(Object id, Path path)
      Assigns the specified path value to the given identifier in this path group. If the given identifier doesn't exist in this path group, it is added, otherwise, the current value associated with the identifier is replaced with the given path value. If the path value is null the given identifier is removed from this path group if it existed; otherwise, no action is taken.
      Parameters:
      id - the identifier
      path - the path to associate with the identifier or null
    • ghostPath

      public void ghostPath(Path path)
      Adds a path associated with the new unique identifier to this path group.
      Parameters:
      path - the path to associate the new unique identifier in this path group
    • keys

      public Set<Object> keys()
      Gets all identifiers of this path group.

      The order of identifiers in the returned list is undefined.

      Returns:
      all identifiers of this path group
    • paths

      public List<Path> paths()
      Gets paths associated with all identifiers in this path group.

      The order of paths in the returned list is undefined.

      Returns:
      paths associated with all identifiers in this path group
    • roots

      public List<Path> roots()
      Gets root paths in this path group.

      If multiple identifiers are associated with the same path value in the group, the path value is added to the returned list only once. Paths that are descendants of other paths in the group are not added to the returned list.

      The order of paths in the returned list is undefined.

      Returns:
      unique root paths in this path group
    • sizeInBytes

      public long sizeInBytes() throws IOException
      Gets the number of bytes in root paths of this path group. The method sums the size of all root path entries in the group. If the path entry is a directory it calculates the total size of the files in the directory. If the path entry is a file, it takes its size.
      Returns:
      the total number of bytes in root paths of this path group
      Throws:
      IOException - If an I/O error occurs
    • resolveAt

      public PathGroup resolveAt(Path root)
      Creates a copy of this path group with all paths resolved against the given root. Taken action is equivalent to creating a copy of this path group and calling root.resolve() on every path in the copy.
      Parameters:
      root - the root against which to resolve paths
      Returns:
      a new path group resolved against the given root path
    • copy

      public void copy(PathGroup dst, CopyOption... options) throws IOException
      Copies files/directories from the locations in the path group into the locations of the given path group. For every identifier found in this and the given group, copy the associated file or directory from the location specified by the path value associated with the identifier in this group into the location associated with the identifier in the given group.
      Parameters:
      dst - the destination path group
      Throws:
      IOException - If an I/O error occurs
    • move

      public void move(PathGroup dst, CopyOption... options) throws IOException
      Similar to copy(PathGroup, CopyOption...) but moves files/directories instead of copying.
      Parameters:
      dst - the destination path group
      Throws:
      IOException - If an I/O error occurs
    • transform

      public void transform(PathGroup dst, PathGroup.TransformHandler handler) throws IOException
      Similar to copy(PathGroup, CopyOption...) but uses the given handler to transform paths instead of coping.
      Parameters:
      dst - the destination path group
      handler - the path transformation handler
      Throws:
      IOException - If an I/O error occurs