Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.flow; |
| 2 | |
| 3 | import org.onlab.onos.event.AbstractEvent; |
| 4 | |
| 5 | /** |
| 6 | * Describes flow rule batch event. |
| 7 | */ |
| 8 | public final class FlowRuleBatchEvent extends AbstractEvent<FlowRuleBatchEvent.Type, FlowRuleBatchRequest> { |
| 9 | |
| 10 | /** |
| 11 | * Type of flow rule events. |
| 12 | */ |
| 13 | public enum Type { |
| 14 | |
| 15 | /** |
| 16 | * Signifies that a batch operation has been initiated. |
| 17 | */ |
| 18 | BATCH_OPERATION_REQUESTED, |
| 19 | |
| 20 | /** |
| 21 | * Signifies that a batch operation has completed. |
| 22 | */ |
| 23 | BATCH_OPERATION_COMPLETED, |
| 24 | } |
| 25 | |
| 26 | private final CompletedBatchOperation result; |
| 27 | |
| 28 | /** |
| 29 | * Constructs a new FlowRuleBatchEvent. |
| 30 | * @param request batch operation request. |
| 31 | * @return event. |
| 32 | */ |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame^] | 33 | public static FlowRuleBatchEvent requested(FlowRuleBatchRequest request) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 34 | FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_REQUESTED, request, null); |
| 35 | return event; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Constructs a new FlowRuleBatchEvent. |
| 40 | * @param request batch operation request. |
| 41 | * @param result completed batch operation result. |
| 42 | * @return event. |
| 43 | */ |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame^] | 44 | public static FlowRuleBatchEvent completed(FlowRuleBatchRequest request, CompletedBatchOperation result) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 45 | FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_COMPLETED, request, result); |
| 46 | return event; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the result of this batch operation. |
| 51 | * @return batch operation result. |
| 52 | */ |
| 53 | public CompletedBatchOperation result() { |
| 54 | return result; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Creates an event of a given type and for the specified flow rule batch. |
| 59 | * |
| 60 | * @param type flow rule batch event type |
| 61 | * @param batch event flow rule batch subject |
| 62 | */ |
| 63 | private FlowRuleBatchEvent(Type type, FlowRuleBatchRequest request, CompletedBatchOperation result) { |
| 64 | super(type, request); |
| 65 | this.result = result; |
| 66 | } |
| 67 | } |