blob: 6b7b75c6dbbb85f3af66e21f2027bd3f86af82b7 [file] [log] [blame]
Toshio Koide5f260652014-01-30 14:41:12 -08001package net.onrc.onos.ofcontroller.app;
2
3import java.util.Collection;
4import java.util.HashMap;
5import java.util.LinkedList;
6
7/**
8 * This code is valid for the architectural study purpose only.
9 * @author Toshio Koide (t-koide@onlab.us)
10 */
11public class Switch extends NetworkGraphEntity {
12 protected HashMap<Integer, SwitchPort> ports;
13 protected String name;
14
15 public Switch(NetworkGraph graph, String name) {
16 super(graph);
17 this.name = name;
18 ports = new HashMap<Integer, SwitchPort>();
19 }
20
21 public SwitchPort addPort(Integer i) {
22 SwitchPort port = new SwitchPort(this, i);
23 ports.put(port.getPortNumber(), port);
24 return port;
25 }
26
27 public SwitchPort getPort(Integer i) {
28 return ports.get(i);
29 }
30
31 public Collection<SwitchPort> getPorts() {
32 return ports.values();
33 }
34
35 public Collection<Link> getAdjLinks() {
36 LinkedList<Link> links = new LinkedList<Link>();
37 for (SwitchPort port: getPorts()) {
38 Link link = port.getOutgointLink();
39 if (link != null) {
40 links.add(link);
41 }
42 }
43 return links;
44 }
45
46 public String getName() {
47 return name;
48 }
49
50}