blob: 71d5378861dac395bf807bfdc208c9842151b32a [file] [log] [blame]
Toshio Koide4ea84192014-07-31 12:10:12 -07001package net.onrc.onos.api.flowmanager;
2
3import net.onrc.onos.api.batchoperation.BatchOperation;
4import net.onrc.onos.api.batchoperation.BatchOperationEntry;
5
6/**
7 * A list of flow operations.
8 */
9public class FlowBatchOperation extends
10 BatchOperation<BatchOperationEntry<FlowBatchOperation.Operator, ?>> {
11 /**
12 * The flow operations' operators.
13 */
14 public enum Operator {
15 /**
16 * Adds new flow.
17 */
18 ADD,
19
20 /**
21 * Removes the existing flow.
22 */
23 REMOVE,
24 }
25
26 /**
27 * Adds an add-flow operation.
28 *
29 * @param flow the flow to be added
30 * @return the FlowBatchOperation object if succeeded, null otherwise
31 */
Toshio Koidefad1cd52014-08-07 17:10:07 -070032 public FlowBatchOperation addAddFlowOperation(Flow flow) {
Toshio Koide4ea84192014-07-31 12:10:12 -070033 return (null == super.addOperation(
Toshio Koidefad1cd52014-08-07 17:10:07 -070034 new BatchOperationEntry<Operator, Flow>(Operator.ADD, flow)))
Toshio Koide4ea84192014-07-31 12:10:12 -070035 ? null : this;
36 }
37
38 /**
39 * Adds a remove-flow operation.
40 *
41 * @param flowId the ID of flow to be removed
42 * @return the FlowBatchOperation object if succeeded, null otherwise
43 */
44 public FlowBatchOperation addRemoveFlowOperation(FlowId flowId) {
45 return (null == super.addOperation(
46 new BatchOperationEntry<Operator, FlowId>(Operator.REMOVE, flowId)))
47 ? null : this;
48 }
49}