blob: f59bee54124283ec2431fc6341d3a6064be4e72f [file] [log] [blame]
Toshio Koide4ea84192014-07-31 12:10:12 -07001package net.onrc.onos.api.flowmanager;
2
Toshio Koide3c846312014-08-21 19:47:15 -07003import java.util.List;
4
Toshio Koide4ea84192014-07-31 12:10:12 -07005import net.onrc.onos.api.batchoperation.BatchOperation;
6import net.onrc.onos.api.batchoperation.BatchOperationEntry;
7
8/**
9 * A list of flow operations.
10 */
11public class FlowBatchOperation extends
12 BatchOperation<BatchOperationEntry<FlowBatchOperation.Operator, ?>> {
13 /**
14 * The flow operations' operators.
15 */
16 public enum Operator {
17 /**
18 * Adds new flow.
19 */
20 ADD,
21
22 /**
23 * Removes the existing flow.
24 */
25 REMOVE,
26 }
27
28 /**
Toshio Koide3c846312014-08-21 19:47:15 -070029 * Creates new {@link FlowBatchOperation} object.
30 */
31 public FlowBatchOperation() {
32 super();
33 }
34
35 /**
36 * Creates new {@link FlowBatchOperation} object from a list of flow batch
37 * operation entries.
38 *
39 * @param batchOperations the list of flow batch operation entries
40 */
41 public FlowBatchOperation(
42 List<BatchOperationEntry<FlowBatchOperation.Operator, ?>> batchOperations) {
43 super(batchOperations);
44 }
45
46 /**
Toshio Koide4ea84192014-07-31 12:10:12 -070047 * Adds an add-flow operation.
48 *
49 * @param flow the flow to be added
50 * @return the FlowBatchOperation object if succeeded, null otherwise
51 */
Toshio Koidefad1cd52014-08-07 17:10:07 -070052 public FlowBatchOperation addAddFlowOperation(Flow flow) {
Toshio Koide4ea84192014-07-31 12:10:12 -070053 return (null == super.addOperation(
Toshio Koidefad1cd52014-08-07 17:10:07 -070054 new BatchOperationEntry<Operator, Flow>(Operator.ADD, flow)))
Toshio Koide4ea84192014-07-31 12:10:12 -070055 ? null : this;
56 }
57
58 /**
59 * Adds a remove-flow operation.
60 *
61 * @param flowId the ID of flow to be removed
62 * @return the FlowBatchOperation object if succeeded, null otherwise
63 */
64 public FlowBatchOperation addRemoveFlowOperation(FlowId flowId) {
65 return (null == super.addOperation(
66 new BatchOperationEntry<Operator, FlowId>(Operator.REMOVE, flowId)))
67 ? null : this;
68 }
69}