blob: 4ba33663b25f6732ef3577d90e9544e4d0a00cfd [file] [log] [blame]
Madan Jampani117aaae2014-10-23 10:04:05 -07001package org.onlab.onos.net.flow;
2
3import org.onlab.onos.event.AbstractEvent;
4
5/**
6 * Describes flow rule batch event.
7 */
8public 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 */
33 public static FlowRuleBatchEvent create(FlowRuleBatchRequest request) {
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 */
44 public static FlowRuleBatchEvent create(FlowRuleBatchRequest request, CompletedBatchOperation result) {
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}