@Test @SuppressWarnings("null") public void testStoreItem() throws IOException { Path copyOfGeneric = newGenericSample(); try (FileWorkspace ws = openGenericUsingServiceLoader(copyOfGeneric)) { assertThatThrownBy(() -> ws.store(GENERIC_SA_MULTI, "hello")) .isInstanceOf(IOException.class) .hasCauseInstanceOf(ClassCastException.class); assertThatThrownBy(() -> ws.store(null, "hello")).isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> ws.store(GENERIC_SA_MULTI, null)).isInstanceOf(NullPointerException.class); } }
@Override public void store(WorkspaceItem item, Object value) throws IOException { Objects.requireNonNull(value, "value"); Index.Key key = toKey(item); indexer.checkId(key); handlers.storeValue(key.getFamily(), rootFolder, key.getId(), value); indexer.storeIndex(indexer.loadIndex().withItem(key, toValue(item))); }
FileWorkspaceImpl implements FileWorkspace { @Override public void store(WorkspaceItem item, Object value) throws IOException { Objects.requireNonNull(value, "value"); Index.Key key = toKey(item); indexer.checkId(key); handlers.storeValue(key.getFamily(), rootFolder, key.getId(), value); indexer.storeIndex(indexer.loadIndex().withItem(key, toValue(item))); } }
FileWorkspaceImpl implements FileWorkspace { @Override public void store(WorkspaceItem item, Object value) throws IOException { Objects.requireNonNull(value, "value"); Index.Key key = toKey(item); indexer.checkId(key); handlers.storeValue(key.getFamily(), rootFolder, key.getId(), value); indexer.storeIndex(indexer.loadIndex().withItem(key, toValue(item))); } private  FileWorkspaceImpl(Path indexFile, FileFormat fileFormat, Path rootFolder, Indexer indexer, SafeHandler handlers); }
FileWorkspaceImpl implements FileWorkspace { @Override public void store(WorkspaceItem item, Object value) throws IOException { Objects.requireNonNull(value, "value"); Index.Key key = toKey(item); indexer.checkId(key); handlers.storeValue(key.getFamily(), rootFolder, key.getId(), value); indexer.storeIndex(indexer.loadIndex().withItem(key, toValue(item))); } private  FileWorkspaceImpl(Path indexFile, FileFormat fileFormat, Path rootFolder, Indexer indexer, SafeHandler handlers); @NonNull static Optional<FileFormat> probeFormat(@NonNull Path file); @NonNull static FileWorkspaceImpl create(@NonNull Path file, @NonNull FileFormat format, @NonNull Supplier<Iterable<FamilyHandler>> handlers); @NonNull static FileWorkspaceImpl open(@NonNull Path file, @NonNull FileFormat format, @NonNull Supplier<Iterable<FamilyHandler>> handlers); @Override String getName(); @Override void setName(String name); @Override Collection<WorkspaceFamily> getSupportedFamilies(); @Override Collection<WorkspaceItem> getItems(); @Override Object load(WorkspaceItem item); @Override void store(WorkspaceItem item, Object value); @Override void delete(WorkspaceItem item); @Override void close(); @Override FileFormat getFileFormat(); @Override Path getFile(); @Override Path getRootFolder(); @Override Path getFile(WorkspaceItem item); }
FileWorkspaceImpl implements FileWorkspace { @Override public void store(WorkspaceItem item, Object value) throws IOException { Objects.requireNonNull(value, "value"); Index.Key key = toKey(item); indexer.checkId(key); handlers.storeValue(key.getFamily(), rootFolder, key.getId(), value); indexer.storeIndex(indexer.loadIndex().withItem(key, toValue(item))); } private  FileWorkspaceImpl(Path indexFile, FileFormat fileFormat, Path rootFolder, Indexer indexer, SafeHandler handlers); @NonNull static Optional<FileFormat> probeFormat(@NonNull Path file); @NonNull static FileWorkspaceImpl create(@NonNull Path file, @NonNull FileFormat format, @NonNull Supplier<Iterable<FamilyHandler>> handlers); @NonNull static FileWorkspaceImpl open(@NonNull Path file, @NonNull FileFormat format, @NonNull Supplier<Iterable<FamilyHandler>> handlers); @Override String getName(); @Override void setName(String name); @Override Collection<WorkspaceFamily> getSupportedFamilies(); @Override Collection<WorkspaceItem> getItems(); @Override Object load(WorkspaceItem item); @Override void store(WorkspaceItem item, Object value); @Override void delete(WorkspaceItem item); @Override void close(); @Override FileFormat getFileFormat(); @Override Path getFile(); @Override Path getRootFolder(); @Override Path getFile(WorkspaceItem item);  }