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