blob: 4a2bcf94ab614cfb55f8b3043505b2feededeb37 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Madan Jampani117aaae2014-10-23 10:04:05 -070016package org.onlab.onos.net.flow;
17
18import java.util.Collections;
19import java.util.List;
20
21import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
22
23import com.google.common.collect.Lists;
24
25public class FlowRuleBatchRequest {
26
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070027 private final int batchId;
Madan Jampani117aaae2014-10-23 10:04:05 -070028 private final List<FlowEntry> toAdd;
29 private final List<FlowEntry> toRemove;
30
Yuta HIGUCHI92891d12014-10-27 20:04:38 -070031 public FlowRuleBatchRequest(int batchId, List<? extends FlowEntry> toAdd, List<? extends FlowEntry> toRemove) {
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070032 this.batchId = batchId;
Madan Jampani117aaae2014-10-23 10:04:05 -070033 this.toAdd = Collections.unmodifiableList(toAdd);
34 this.toRemove = Collections.unmodifiableList(toRemove);
35 }
36
37 public List<FlowEntry> toAdd() {
38 return toAdd;
39 }
40
41 public List<FlowEntry> toRemove() {
42 return toRemove;
43 }
44
45 public FlowRuleBatchOperation asBatchOperation() {
46 List<FlowRuleBatchEntry> entries = Lists.newArrayList();
47 for (FlowEntry e : toAdd) {
48 entries.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, e));
49 }
50 for (FlowEntry e : toRemove) {
51 entries.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, e));
52 }
53 return new FlowRuleBatchOperation(entries);
54 }
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070055
56 public int batchId() {
57 return batchId;
58 }
Madan Jampani117aaae2014-10-23 10:04:05 -070059}