/** * Creates an empty file. */ public ContentWriter createWriter(String name) { checkArgument(!filesContent.containsKey(name), "File [%s] already exists", name); filesContent.put(name, new ArrayList<>()); return new ContentWriter(name, this); }
@Override public String toString() { return String.format("ContentTransaction[%s]", tmpContentWriter.getName()); } }
@Override protected void invoke(ContentTransaction transaction, String value, Context context) throws Exception { transaction.tmpContentWriter.write(value); }
@Override protected void commit(ContentTransaction transaction) { if (throwException.get()) { throw new RuntimeException("Expected exception"); } ContentDump.move( transaction.tmpContentWriter.getName(), tmpDirectory, targetDirectory); }