@Test public void testInitialAttributes() { file.setAttribute("owner", "owner", createUserPrincipal("foo")); file.setAttribute("posix", "group", createGroupPrincipal("bar")); file.setAttribute( "posix", "permissions", ImmutableSet.copyOf(PosixFilePermissions.fromString("rw-r--r--"))); 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); assertThat(provider.get(file, "mode")).isEqualTo(0644); assertThat(provider.get(file, "ctime")).isEqualTo(FileTime.fromMillis(file.getCreationTime())); 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); }
@SuppressWarnings("unchecked") @Override public 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 FileTime.fromMillis(file.getCreationTime()); case "rdev": return 0L; case "dev": return 1L; case "ino": return file.id(); case "nlink": return file.links(); default: return null; } }
UnixAttributeProvider extends AttributeProvider { @SuppressWarnings("unchecked") @Override public 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 FileTime.fromMillis(file.getCreationTime()); case "rdev": return 0L; case "dev": return 1L; case "ino": return file.id(); case "nlink": return file.links(); default: return null; } } }
UnixAttributeProvider extends AttributeProvider { @SuppressWarnings("unchecked") @Override public 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 FileTime.fromMillis(file.getCreationTime()); case "rdev": return 0L; case "dev": return 1L; case "ino": return file.id(); case "nlink": return file.links(); default: return null; } }  }
UnixAttributeProvider extends AttributeProvider { @SuppressWarnings("unchecked") @Override public 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 FileTime.fromMillis(file.getCreationTime()); case "rdev": return 0L; case "dev": return 1L; case "ino": return file.id(); case "nlink": return file.links(); default: return null; } }  @Override String name(); @Override ImmutableSet<String> inherits(); @Override ImmutableSet<String> fixedAttributes(); @Override Class<UnixFileAttributeView> viewType(); @Override UnixFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); @SuppressWarnings("unchecked") @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); }
UnixAttributeProvider extends AttributeProvider { @SuppressWarnings("unchecked") @Override public 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 FileTime.fromMillis(file.getCreationTime()); case "rdev": return 0L; case "dev": return 1L; case "ino": return file.id(); case "nlink": return file.links(); default: return null; } }  @Override String name(); @Override ImmutableSet<String> inherits(); @Override ImmutableSet<String> fixedAttributes(); @Override Class<UnixFileAttributeView> viewType(); @Override UnixFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); @SuppressWarnings("unchecked") @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create);  }