class ZipUtils {

  public static void unzip(BeanByteSource source, Path path) {
    Path absolutePath = path.toAbsolutePath();
    Set<ZipKey> deduplicate = new HashSet<>();
    try (ZipInputStream in = new ZipInputStream(source.openStream())) {
      ZipEntry entry = in.getNextEntry();
      while (entry != null) {
        Path resolved = validateZipPathName(absolutePath, entry);
        if (!entry.isDirectory()) {
          if (deduplicate.add(new ZipKey(entry, resolved))) {
            Files.createDirectories(resolved);
            Files.copy(in, resolved, StandardCopyOption.REPLACE_EXISTING);
          }
        }
        in.closeEntry();
        entry = in.getNextEntry();
      }
    } catch (IOException ex) {
      throw new UncheckedIOException(ex);
    }
  }

  private  ZipUtils();

}