Sho SHIMIZU
Committed by Gerrit Code Review

Refactor: add static factory method in BatchWrite, instead of in IntentStore

Change-Id: Ic0cecc4b3cc4facbc469d2eb87a36c4d5166a6f2
......@@ -24,7 +24,7 @@ import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
public class BatchWrite {
public final class BatchWrite {
public enum OpType {
CREATE_INTENT,
......@@ -36,6 +36,17 @@ public class BatchWrite {
List<Operation> operations = new ArrayList<>();
private BatchWrite() {}
/**
* Returns a new empty batch write operation builder.
*
* @return BatchWrite
*/
public static BatchWrite newInstance() {
return new BatchWrite();
}
public List<Operation> operations() {
return Collections.unmodifiableList(operations);
}
......
......@@ -110,16 +110,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
*/
void removeInstalledIntents(IntentId intentId);
/**
* Returns a new empty batch write operation buider.
*
* @return BatchWrite
*/
default BatchWrite newBatchWrite() {
return new BatchWrite();
}
/**
* Execute writes in a batch.
*
......
......@@ -768,7 +768,7 @@ public class IntentManager
}
private void buildIntentUpdates() {
BatchWrite batchWrite = store.newBatchWrite();
BatchWrite batchWrite = BatchWrite.newInstance();
// create context and record new request to store
for (IntentOperation op : ops.operations()) {
......@@ -806,7 +806,7 @@ public class IntentManager
return flowRuleService.applyBatch(batch);
} else {
// there are no flow rule batches; finalize the intent update
BatchWrite batchWrite = store.newBatchWrite();
BatchWrite batchWrite = BatchWrite.newInstance();
for (IntentUpdate update : intentUpdates) {
update.finalizeStates(batchWrite);
}
......