code: public static short translatePosixPermissionToMode(Set<PosixFilePermission> permission) {
      int mode = 0;
      for (PosixFilePermission action : PosixFilePermission.values()) {
        mode = mode << 1;
        mode += permission.contains(action) ? 1 : 0;
      }
      return (short) mode;
    }
docs: Translate posix file permissions to short mode.
  
  @param permission posix file permission
  @return mode for file