Yuta HIGUCHI | 54ab8cd | 2014-02-11 09:43:34 -0800 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.networkgraph; |
| 2 | |
| 3 | import java.net.InetAddress; |
| 4 | import java.util.HashSet; |
| 5 | import java.util.LinkedList; |
| 6 | import java.util.List; |
| 7 | import java.util.Set; |
| 8 | |
| 9 | import net.floodlightcontroller.util.MACAddress; |
| 10 | import net.onrc.onos.ofcontroller.networkgraph.PortEvent.SwitchPort; |
| 11 | |
| 12 | /** |
Yuta HIGUCHI | dac4caa | 2014-02-11 18:51:35 -0800 | [diff] [blame] | 13 | * Self-contained Device event Object |
Yuta HIGUCHI | 54ab8cd | 2014-02-11 09:43:34 -0800 | [diff] [blame] | 14 | * |
| 15 | * TODO: We probably want common base class/interface for Self-Contained Event Object |
| 16 | * |
| 17 | */ |
| 18 | public class DeviceEvent { |
| 19 | private final MACAddress mac; |
| 20 | protected List<SwitchPort> attachmentPoints; |
| 21 | protected Set<InetAddress> ipAddresses; |
| 22 | |
| 23 | public DeviceEvent(MACAddress mac) { |
| 24 | this.mac = mac; |
| 25 | this.attachmentPoints = new LinkedList<>(); |
| 26 | this.ipAddresses = new HashSet<>(); |
| 27 | } |
| 28 | |
| 29 | public MACAddress getMac() { |
| 30 | return mac; |
| 31 | } |
| 32 | |
| 33 | public List<SwitchPort> getAttachmentPoints() { |
| 34 | return attachmentPoints; |
| 35 | } |
| 36 | |
| 37 | public void setAttachmentPoints(List<SwitchPort> attachmentPoints) { |
| 38 | this.attachmentPoints = attachmentPoints; |
| 39 | } |
| 40 | |
| 41 | boolean addIpAddress(InetAddress addr) { |
| 42 | return this.ipAddresses.add(addr); |
| 43 | } |
| 44 | |
| 45 | boolean removeIpAddress(InetAddress addr) { |
| 46 | return this.ipAddresses.remove(addr); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public String toString() { |
| 51 | return "[DeviceEvent " + mac + " attachmentPoints:" + attachmentPoints + " ipAddr:" + ipAddresses + "]"; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | } |