@Test public void testSet() { FileTime time = FileTime.fromMillis(0L); assertSetAndGetSucceeds("creationTime", time); assertSetAndGetSucceeds("lastModifiedTime", time); assertSetAndGetSucceeds("lastAccessTime", time); assertSetFails("fileKey", 3L); assertSetFails("size", 1L); assertSetFails("isRegularFile", true); assertSetFails("isDirectory", true); assertSetFails("isSymbolicLink", true); assertSetFails("isOther", true); assertSetFails("creationTime", "foo"); }
@Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "creationTime": checkNotCreate(view, attribute, create); file.setCreationTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastAccessTime": checkNotCreate(view, attribute, create); file.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastModifiedTime": checkNotCreate(view, attribute, create); file.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "size": case "fileKey": case "isDirectory": case "isRegularFile": case "isSymbolicLink": case "isOther": throw unsettable(view, attribute, create); default: } }
BasicAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "creationTime": checkNotCreate(view, attribute, create); file.setCreationTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastAccessTime": checkNotCreate(view, attribute, create); file.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastModifiedTime": checkNotCreate(view, attribute, create); file.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "size": case "fileKey": case "isDirectory": case "isRegularFile": case "isSymbolicLink": case "isOther": throw unsettable(view, attribute, create); default: } } }
BasicAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "creationTime": checkNotCreate(view, attribute, create); file.setCreationTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastAccessTime": checkNotCreate(view, attribute, create); file.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastModifiedTime": checkNotCreate(view, attribute, create); file.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "size": case "fileKey": case "isDirectory": case "isRegularFile": case "isSymbolicLink": case "isOther": throw unsettable(view, attribute, create); default: } }  }
BasicAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "creationTime": checkNotCreate(view, attribute, create); file.setCreationTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastAccessTime": checkNotCreate(view, attribute, create); file.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastModifiedTime": checkNotCreate(view, attribute, create); file.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "size": case "fileKey": case "isDirectory": case "isRegularFile": case "isSymbolicLink": case "isOther": throw unsettable(view, attribute, create); default: } }  @Override String name(); @Override ImmutableSet<String> fixedAttributes(); @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); @Override Class<BasicFileAttributeView> viewType(); @Override BasicFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); @Override Class<BasicFileAttributes> attributesType(); @Override BasicFileAttributes readAttributes(File file); }
BasicAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "creationTime": checkNotCreate(view, attribute, create); file.setCreationTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastAccessTime": checkNotCreate(view, attribute, create); file.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "lastModifiedTime": checkNotCreate(view, attribute, create); file.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis()); break; case "size": case "fileKey": case "isDirectory": case "isRegularFile": case "isSymbolicLink": case "isOther": throw unsettable(view, attribute, create); default: } }  @Override String name(); @Override ImmutableSet<String> fixedAttributes(); @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); @Override Class<BasicFileAttributeView> viewType(); @Override BasicFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); @Override Class<BasicFileAttributes> attributesType(); @Override BasicFileAttributes readAttributes(File file);  }