Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.net.flow; |
| 2 | |
| 3 | import java.util.Collections; |
| 4 | import java.util.List; |
| 5 | |
| 6 | import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; |
| 7 | |
| 8 | import com.google.common.collect.Lists; |
| 9 | |
| 10 | public 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 | } |