@@ -0,0 +1,1670 @@
+package net.onrc.onos.intent;%0A%0Aimport java.util.Collection;%0Aimport java.util.Collections;%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.LinkedList;%0A%0Aimport net.onrc.onos.ofcontroller.networkgraph.Link;%0A%0A/**%0A * @author Toshio Koide (t-koide@onlab.us)%0A */%0Apublic class PathIntents %7B%0A%09protected LinkedList%3CPathIntent%3E intents = new LinkedList%3CPathIntent%3E();%0A%09protected HashMap%3CLink, HashSet%3CPathIntent%3E%3E linkToIntents = new HashMap%3CLink, HashSet%3CPathIntent%3E%3E();%0A%0A%09public void addIntent(PathIntent intent) %7B%0A%09%09intents.add(intent);%0A%09%09for (Link link: intent.getPath()) %7B%0A%09%09%09HashSet%3CPathIntent%3E value = linkToIntents.get(link);%0A%09%09%09if (value == null) %7B%0A%09%09%09%09value = new HashSet%3CPathIntent%3E();%0A%09%09%09%09linkToIntents.put(link, value);%0A%09%09%09%7D%0A%09%09%09value.add(intent);%0A%09%09%7D%0A%09%7D%0A%0A%09public void addIntents(PathIntents intents) %7B%0A%09%09for(PathIntent intent: intents.getIntents()) %7B%0A%09%09%09addIntent(intent);%0A%09%09%7D%0A%09%7D%0A%0A%09public Collection%3CPathIntent%3E getIntentByLink(Link link) %7B%0A%09%09return Collections.unmodifiableCollection(linkToIntents.get(link));%0A%09%7D%0A%0A%09public Collection%3CPathIntent%3E getIntents() %7B%0A%09%09return Collections.unmodifiableCollection(intents);%0A%09%7D%0A%0A%09/**%0A%09 * calculate available bandwidth of specified link%0A%09 * @param link%0A%09 * @return%0A%09 */%0A%09public Double getAvailableBandwidth(Link link) %7B%0A%09%09Double bandwidth = link.getCapacity();%0A%09%09if (!bandwidth.isInfinite() && linkToIntents.containsKey(link)) %7B%0A%09%09%09for (PathIntent intent: getIntentByLink(link)) %7B%0A%09%09%09%09Double intentBandwidth = intent.getBandwidth();%0A%09%09%09%09if (intentBandwidth == null %7C%7C intentBandwidth.isInfinite() %7C%7C intentBandwidth.isNaN())%0A%09%09%09%09%09continue;%0A%09%09%09%09bandwidth -= intentBandwidth;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return bandwidth;%0A%09%7D%0A%7D%0A

Add a PathIntents class.