Toshio Koide | a5611ce | 2014-08-22 15:16:51 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowmanager; |
| 2 | |
| 3 | import java.util.Set; |
| 4 | |
| 5 | import net.onrc.onos.api.flowmanager.Flow; |
| 6 | import net.onrc.onos.api.flowmanager.FlowId; |
| 7 | import net.onrc.onos.api.flowmanager.FlowState; |
| 8 | |
| 9 | /** |
| 10 | * Interface of the flow map. |
| 11 | */ |
| 12 | interface FlowMap { |
| 13 | /** |
| 14 | * Gets {@link Flow} object having {@link FlowId} as its ID from the map. |
| 15 | * |
| 16 | * @param id the {@link FlowId} to be used for getting the object |
| 17 | * @return {@link Flow} object if exists, null otherwise |
| 18 | */ |
| 19 | Flow get(FlowId id); |
| 20 | |
| 21 | /** |
| 22 | * Puts {@link Flow} object to the map. |
| 23 | * |
| 24 | * @param flow the {@link Flow} object |
| 25 | * @return true if the object was successfully added |
| 26 | */ |
| 27 | boolean put(Flow flow); |
| 28 | |
| 29 | /** |
| 30 | * Removes {@link Flow} object from the map. |
| 31 | * |
| 32 | * @param id the {@link FlowId} to be used for removing the object |
| 33 | * @return the removed {@link Flow} object if exists, null otherwise |
| 34 | */ |
| 35 | Flow remove(FlowId id); |
| 36 | |
| 37 | /** |
| 38 | * Gets all {@link Flow} objects existing in the map. |
| 39 | * <p> |
| 40 | * The changes to the returned set does not affect the original map. |
| 41 | * |
| 42 | * @return a set of {@link Flow} objects |
| 43 | */ |
| 44 | Set<Flow> getAll(); |
| 45 | |
| 46 | /** |
| 47 | * Sets {@link FlowState} to the specified {@link Flow} object. |
| 48 | * |
| 49 | * @param id the {@link FlowId} of the {@link Flow} |
| 50 | * @param state the {@link FlowState} to be set |
| 51 | * @param expectedState the {@link FlowState} expected as the previous state |
| 52 | * @return true if the ID existed, the previous state was the expected state |
| 53 | * and successfully updated the state |
| 54 | */ |
| 55 | boolean setState(FlowId id, FlowState state, FlowState expectedState); |
| 56 | |
| 57 | /** |
| 58 | * Gets {@link FlowState} of the specified {@link Flow} object. |
| 59 | * |
| 60 | * @param id the {@link FlowId} of the {@link Flow} |
| 61 | * @return the {@link FlowState} of the {@link Flow} or null if the |
| 62 | * {@link Flow} does not exist |
| 63 | */ |
| 64 | FlowState getState(FlowId id); |
| 65 | |
| 66 | /** |
| 67 | * Adds a listener for listening events related to the map. |
| 68 | * |
| 69 | * @param listener the {@link FlowMapEventListener} to be added |
| 70 | */ |
| 71 | void addListener(FlowMapEventListener listener); |
| 72 | |
| 73 | /** |
| 74 | * Removes a listener for listening events related to the map. |
| 75 | * |
| 76 | * @param listener the {@link FlowMapEventListener} to be removed |
| 77 | */ |
| 78 | void removeListener(FlowMapEventListener listener); |
| 79 | } |