blob: d5c762dbea006836808339661ba3578b020899f9 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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 Jampani117aaae2014-10-23 10:04:05 -070016package org.onlab.onos.net.flow;
17
18import org.onlab.onos.event.AbstractEvent;
19
20/**
21 * Describes flow rule batch event.
22 */
23public 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 HIGUCHI9def0472014-10-23 15:51:10 -070048 public static FlowRuleBatchEvent requested(FlowRuleBatchRequest request) {
Madan Jampani117aaae2014-10-23 10:04:05 -070049 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 HIGUCHI9def0472014-10-23 15:51:10 -070059 public static FlowRuleBatchEvent completed(FlowRuleBatchRequest request, CompletedBatchOperation result) {
Madan Jampani117aaae2014-10-23 10:04:05 -070060 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}