Pavlin Radoslavov | 3f9ba65 | 2013-10-25 17:19:01 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.util; |
| 2 | |
| 3 | /** |
| 4 | * Class for encapsulating events with event-related data entry. |
| 5 | */ |
| 6 | public class EventEntry<T> { |
| 7 | /** |
| 8 | * The event types. |
| 9 | */ |
| 10 | public enum Type { |
| 11 | ENTRY_ADD, // Add or update an entry |
| 12 | ENTRY_REMOVE // Remove an entry |
| 13 | } |
| 14 | |
| 15 | private Type eventType; // The event type |
| 16 | private T eventData; // The relevant event data entry |
| 17 | |
| 18 | /** |
| 19 | * Constructor for a given event type and event-related data entry. |
| 20 | * |
| 21 | * @param eventType the event type. |
| 22 | * @param eventData the event data entry. |
| 23 | */ |
| 24 | public EventEntry(EventEntry.Type eventType, T eventData) { |
| 25 | this.eventType = eventType; |
| 26 | this.eventData = eventData; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Test whether the event type is ENTRY_ADD. |
| 31 | * |
| 32 | * @return true if the event type is ENTRY_ADD, otherwise false. |
| 33 | */ |
| 34 | public boolean isAdd() { |
| 35 | return (this.eventType == Type.ENTRY_ADD); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Test whether the event type is ENTRY_REMOVE. |
| 40 | * |
| 41 | * @return true if the event type is ENTRY_REMOVE, otherwise false. |
| 42 | */ |
| 43 | public boolean isRemove() { |
| 44 | return (this.eventType == Type.ENTRY_REMOVE); |
| 45 | } |
| 46 | } |