Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.flowmanager; |
| 2 | |
| 3 | import net.onrc.onos.api.batchoperation.BatchOperation; |
| 4 | import net.onrc.onos.api.batchoperation.BatchOperationEntry; |
| 5 | |
| 6 | /** |
| 7 | * A list of flow operations. |
| 8 | */ |
| 9 | public 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 Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 32 | public FlowBatchOperation addAddFlowOperation(Flow flow) { |
Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame] | 33 | return (null == super.addOperation( |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 34 | new BatchOperationEntry<Operator, Flow>(Operator.ADD, flow))) |
Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame] | 35 | ? 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 | } |