@SuppressWarnings("unchecked")
  public <V extends FileAttributeView> @Nullable V getFileAttributeView(
      FileLookup lookup, Class<V> type) {
    AttributeProvider provider = providersByViewType.get(type);

    if (provider != null) {
      return (V) provider.view(lookup, createInheritedViews(lookup, provider));
    }

    return null;
  }
@SuppressWarnings("ConstantConditions")
  @Test
  public void testGetFileAttributeView() throws IOException {
    final File file = createFile();
    service.setInitialAttributes(file);

    FileLookup fileLookup =
        new FileLookup() {
          @Override
          public File lookup() throws IOException {
            return file;
          }
        };

    assertThat(service.getFileAttributeView(fileLookup, TestAttributeView.class)).isNotNull();
    assertThat(service.getFileAttributeView(fileLookup, BasicFileAttributeView.class)).isNotNull();

    TestAttributes attrs =
        service.getFileAttributeView(fileLookup, TestAttributeView.class).readAttributes();
    assertThat(attrs.foo()).isEqualTo("hello");
    assertThat(attrs.bar()).isEqualTo(0);
    assertThat(attrs.baz()).isEqualTo(1);
  }