Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent.runtime; |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 2 | |
| 3 | import java.util.HashMap; |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 4 | import java.util.HashSet; |
| 5 | import java.util.Map; |
| 6 | import java.util.Map.Entry; |
| 7 | import java.util.Set; |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 8 | |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 9 | import net.onrc.onos.core.intent.Intent.IntentState; |
Toshio Koide | fdb7593 | 2014-06-16 17:59:24 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
| 12 | * Used by PathCalcRuntimeModule and PlanInstallModule |
| 13 | * to notify path intents' state changes. |
| 14 | */ |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 15 | public class IntentStateList { |
| 16 | protected Map<String, IntentState> intentMap; |
| 17 | public Set<Long> domainSwitchDpids; |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 18 | |
Toshio Koide | fdb7593 | 2014-06-16 17:59:24 -0700 | [diff] [blame] | 19 | /** |
| 20 | * Constructor to make new IntentStateList. |
| 21 | */ |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 22 | public IntentStateList() { |
| 23 | intentMap = new HashMap<String, IntentState>(); |
| 24 | domainSwitchDpids = new HashSet<Long>(); |
| 25 | } |
| 26 | |
Toshio Koide | fdb7593 | 2014-06-16 17:59:24 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Adds or modifies intent's state. |
| 29 | * |
| 30 | * @param id an intent ID for the state. |
| 31 | * @param state a state for the intent. |
| 32 | * @return the previous state, or null if there was no intents. |
| 33 | */ |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 34 | public IntentState put(String id, IntentState state) { |
| 35 | return intentMap.put(id, state); |
| 36 | } |
| 37 | |
Toshio Koide | fdb7593 | 2014-06-16 17:59:24 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Returns a set of view of the intent states. |
| 40 | * |
| 41 | * @return a set of intent IDs and intent states. |
| 42 | */ |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 43 | public Set<Entry<String, IntentState>> entrySet() { |
| 44 | return intentMap.entrySet(); |
| 45 | } |
| 46 | |
Toshio Koide | fdb7593 | 2014-06-16 17:59:24 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Removes all of intent states from this object. |
| 49 | */ |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 50 | public void clear() { |
| 51 | intentMap.clear(); |
| 52 | } |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 53 | } |