@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;
    }
  }
@Test
  public void testInitialAttributes() {
    // unix provider relies on other providers to set their initial attributes
    file.setAttribute("owner", "owner", createUserPrincipal("foo"));
    file.setAttribute("posix", "group", createGroupPrincipal("bar"));
    file.setAttribute(
        "posix", "permissions", ImmutableSet.copyOf(PosixFilePermissions.fromString("rw-r--r--")));

    // these are pretty much meaningless here since they aren't properties this
    // file system actually has, so don't really care about the exact value of these
    assertThat(provider.get(file, "uid")).isInstanceOf(Integer.class);
    assertThat(provider.get(file, "gid")).isInstanceOf(Integer.class);
    assertThat(provider.get(file, "rdev")).isEqualTo(0L);
    assertThat(provider.get(file, "dev")).isEqualTo(1L);
    assertThat(provider.get(file, "ino")).isInstanceOf(Integer.class);

    // these have logical origins in attributes from other views
    assertThat(provider.get(file, "mode")).isEqualTo(0644); // rw-r--r--
    assertThat(provider.get(file, "ctime")).isEqualTo(file.getCreationTime());

    // this is based on a property this file system does actually have
    assertThat(provider.get(file, "nlink")).isEqualTo(1);

    file.incrementLinkCount();
    assertThat(provider.get(file, "nlink")).isEqualTo(2);
    file.decrementLinkCount();
    assertThat(provider.get(file, "nlink")).isEqualTo(1);
  }