blob: 0414fcb00639b244af0040cb20bf873075d07060 [file] [log] [blame]
Madan Jampani117aaae2014-10-23 10:04:05 -07001package org.onlab.onos.net.flow;
2
3import java.util.Collections;
4import java.util.List;
5
6import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
7
8import com.google.common.collect.Lists;
9
10public class FlowRuleBatchRequest {
11
12 private final List<FlowEntry> toAdd;
13 private final List<FlowEntry> toRemove;
14
15 public FlowRuleBatchRequest(List<FlowEntry> toAdd, List<FlowEntry> toRemove) {
16 this.toAdd = Collections.unmodifiableList(toAdd);
17 this.toRemove = Collections.unmodifiableList(toRemove);
18 }
19
20 public List<FlowEntry> toAdd() {
21 return toAdd;
22 }
23
24 public List<FlowEntry> toRemove() {
25 return toRemove;
26 }
27
28 public FlowRuleBatchOperation asBatchOperation() {
29 List<FlowRuleBatchEntry> entries = Lists.newArrayList();
30 for (FlowEntry e : toAdd) {
31 entries.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, e));
32 }
33 for (FlowEntry e : toRemove) {
34 entries.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, e));
35 }
36 return new FlowRuleBatchOperation(entries);
37 }
38}