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 | |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 12 | private final int batchId; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 13 | private final List<FlowEntry> toAdd; |
| 14 | private final List<FlowEntry> toRemove; |
| 15 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 16 | public FlowRuleBatchRequest(int batchId, List<? extends FlowEntry> toAdd, List<? extends FlowEntry> toRemove) { |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 17 | this.batchId = batchId; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 18 | this.toAdd = Collections.unmodifiableList(toAdd); |
| 19 | this.toRemove = Collections.unmodifiableList(toRemove); |
| 20 | } |
| 21 | |
| 22 | public List<FlowEntry> toAdd() { |
| 23 | return toAdd; |
| 24 | } |
| 25 | |
| 26 | public List<FlowEntry> toRemove() { |
| 27 | return toRemove; |
| 28 | } |
| 29 | |
| 30 | public FlowRuleBatchOperation asBatchOperation() { |
| 31 | List<FlowRuleBatchEntry> entries = Lists.newArrayList(); |
| 32 | for (FlowEntry e : toAdd) { |
| 33 | entries.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, e)); |
| 34 | } |
| 35 | for (FlowEntry e : toRemove) { |
| 36 | entries.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, e)); |
| 37 | } |
| 38 | return new FlowRuleBatchOperation(entries); |
| 39 | } |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 40 | |
| 41 | public int batchId() { |
| 42 | return batchId; |
| 43 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 44 | } |