class UnixAttributeProvider extends AttributeProvider {

  private static final ImmutableSet<String> ATTRIBUTES =
      ImmutableSet.of("uid", "ino", "dev", "nlink", "rdev", "ctime", "mode", "gid");

  private static final ImmutableSet<String> INHERITED_VIEWS =
      ImmutableSet.of("basic", "owner", "posix");

  private final AtomicInteger uidGenerator = new AtomicInteger();
  private final ConcurrentMap<Object, Integer> idCache = new ConcurrentHashMap<>();

  @Override
  public String name() {
    return "unix";
  }

  @Override
  public ImmutableSet<String> inherits() {
    return INHERITED_VIEWS;
  }

  @Override
  public ImmutableSet<String> fixedAttributes() {
    return ATTRIBUTES;
  }

  @Override
  public Class<UnixFileAttributeView> viewType() {
    return UnixFileAttributeView.class;
  }

  @Override
  public UnixFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
    // This method should not be called... and it cannot be called through the public APIs in
    // java.nio.file since there is no public UnixFileAttributeView type.
    throw new UnsupportedOperationException();
  }

  // TODO(cgdecker): Since we can now guarantee that the owner/group for an file are our own
  // implementation of UserPrincipal/GroupPrincipal, it would be nice to have them store a unique
  // ID themselves and just get that rather than doing caching here. Then this could be a singleton
  // like the rest of the AttributeProviders. However, that would require a way for the owner/posix
  // providers to create their default principals using the lookup service for the specific file
  // system.

  /** Returns an ID that is guaranteed to be the same for any invocation with equal objects. */
  private Integer getUniqueId(Object object) {
    Integer id = idCache.get(object);
    if (id == null) {
      id = uidGenerator.incrementAndGet();
      Integer existing = idCache.putIfAbsent(object, id);
      if (existing != null) {
        return existing;
      }
    }
    return id;
  }

  @SuppressWarnings("unchecked")
  @Override
  public @Nullable Object get(File file, String attribute) {
    switch (attribute) {
      case "uid":
        UserPrincipal user = (UserPrincipal) file.getAttribute("owner", "owner");
        return getUniqueId(user);
      case "gid":
        GroupPrincipal group = (GroupPrincipal) file.getAttribute("posix", "group");
        return getUniqueId(group);
      case "mode":
        Set<PosixFilePermission> permissions =
            (Set<PosixFilePermission>) file.getAttribute("posix", "permissions");
        return toMode(permissions);
      case "ctime":
        return file.getCreationTime();
      case "rdev":
        return 0L;
      case "dev":
        return 1L;
      case "ino":
        return file.id();
      case "nlink":
        return file.links();
      default:
        return null;
    }
  }

  @Override
  public void set(File file, String view, String attribute, Object value, boolean create) {
    throw unsettable(view, attribute, create);
  }

  @SuppressWarnings("OctalInteger")
  private static int toMode(Set<PosixFilePermission> permissions) {<FILL_FUNCTION_BODY>}
}

    int result = 0;
    for (PosixFilePermission permission : permissions) {
      checkNotNull(permission);
      switch (permission) {
        case OWNER_READ:
          result |= 0400; // note: octal numbers
          break;
        case OWNER_WRITE:
          result |= 0200;
          break;
        case OWNER_EXECUTE:
          result |= 0100;
          break;
        case GROUP_READ:
          result |= 0040;
          break;
        case GROUP_WRITE:
          result |= 0020;
          break;
        case GROUP_EXECUTE:
          result |= 0010;
          break;
        case OTHERS_READ:
          result |= 0004;
          break;
        case OTHERS_WRITE:
          result |= 0002;
          break;
        case OTHERS_EXECUTE:
          result |= 0001;
          break;
        default:
          throw new AssertionError(); // no other possible values
      }
    }
    return result;
  
<methods>public non-sealed void <init>() ,public ImmutableSet<java.lang.String> attributes(com.google.common.jimfs.File) ,public Class<? extends java.nio.file.attribute.BasicFileAttributes> attributesType() ,public ImmutableMap<java.lang.String,?> defaultValues(Map<java.lang.String,?>) ,public abstract ImmutableSet<java.lang.String> fixedAttributes() ,public abstract java.lang.Object get(com.google.common.jimfs.File, java.lang.String) ,public ImmutableSet<java.lang.String> inherits() ,public abstract java.lang.String name() ,public java.nio.file.attribute.BasicFileAttributes readAttributes(com.google.common.jimfs.File) ,public abstract void set(com.google.common.jimfs.File, java.lang.String, java.lang.String, java.lang.Object, boolean) ,public boolean supports(java.lang.String) ,public abstract java.nio.file.attribute.FileAttributeView view(com.google.common.jimfs.FileLookup, ImmutableMap<java.lang.String,java.nio.file.attribute.FileAttributeView>) ,public abstract Class<? extends java.nio.file.attribute.FileAttributeView> viewType() <variables>