blob: 6103c648362f2345925ee2989b18419c629f832c [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent.runtime;
Toshio Koide066506e2014-02-20 19:52:09 -08002
3import java.util.HashMap;
TeruUf9111652014-05-14 23:10:35 -07004import java.util.HashSet;
5import java.util.Map;
6import java.util.Map.Entry;
7import java.util.Set;
Toshio Koide066506e2014-02-20 19:52:09 -08008
Jonathan Hartaa380972014-04-03 10:24:46 -07009import net.onrc.onos.core.intent.Intent.IntentState;
Toshio Koidefdb75932014-06-16 17:59:24 -070010
11/**
12 * Used by PathCalcRuntimeModule and PlanInstallModule
13 * to notify path intents' state changes.
14 */
TeruUf9111652014-05-14 23:10:35 -070015public class IntentStateList {
16 protected Map<String, IntentState> intentMap;
17 public Set<Long> domainSwitchDpids;
Toshio Koide066506e2014-02-20 19:52:09 -080018
Toshio Koidefdb75932014-06-16 17:59:24 -070019 /**
20 * Constructor to make new IntentStateList.
21 */
TeruUf9111652014-05-14 23:10:35 -070022 public IntentStateList() {
23 intentMap = new HashMap<String, IntentState>();
24 domainSwitchDpids = new HashSet<Long>();
25 }
26
Toshio Koidefdb75932014-06-16 17:59:24 -070027 /**
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 */
TeruUf9111652014-05-14 23:10:35 -070034 public IntentState put(String id, IntentState state) {
35 return intentMap.put(id, state);
36 }
37
Toshio Koidefdb75932014-06-16 17:59:24 -070038 /**
39 * Returns a set of view of the intent states.
40 *
41 * @return a set of intent IDs and intent states.
42 */
TeruUf9111652014-05-14 23:10:35 -070043 public Set<Entry<String, IntentState>> entrySet() {
44 return intentMap.entrySet();
45 }
46
Toshio Koidefdb75932014-06-16 17:59:24 -070047 /**
48 * Removes all of intent states from this object.
49 */
TeruUf9111652014-05-14 23:10:35 -070050 public void clear() {
51 intentMap.clear();
52 }
Toshio Koide066506e2014-02-20 19:52:09 -080053}