class PathToPathMetadata implements Function<Path, PathMetadata> {

  @Override
  public PathMetadata apply(@Nonnull Path location) {
    try {
      FileSystem fs = location.getFileSystem(conf);
      FileStatus fileStatus = fs.getFileStatus(location);
      FileChecksum checksum = null;
      if (fileStatus.isFile()) {
        checksum = fs.getFileChecksum(location);
      }

      long modificationTime = 0;
      List<PathMetadata> childPathDescriptors = new ArrayList<>();

      if (fileStatus.isDirectory()) {
        FileStatus[] childStatuses = fs.listStatus(location);
        for (FileStatus childStatus : childStatuses) {
          childPathDescriptors.add(apply(childStatus.getPath()));
        }
      } else {
        modificationTime = fileStatus.getModificationTime();
      }

      return new PathMetadata(location, modificationTime, checksum, childPathDescriptors);
    } catch (IOException e) {
      throw new CircusTrainException("Unable to compute digest for location " + location.toString(), e);
    }
  }

  public  PathToPathMetadata(Configuration conf);

}