Ayaka Koshibe | 74a2392 | 2014-09-09 16:45:39 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.net.host; |
| 2 | |
| 3 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 4 | |
| 5 | import java.util.Collections; |
| 6 | import java.util.HashSet; |
| 7 | import java.util.Set; |
| 8 | |
| 9 | import org.onlab.onos.net.HostLocation; |
| 10 | import org.onlab.packet.IPv4; |
| 11 | import org.onlab.packet.MACAddress; |
| 12 | |
| 13 | public class DefaultHostDescription implements HostDescription { |
| 14 | |
| 15 | private final MACAddress mac; |
| 16 | private final short vlan; |
| 17 | private final HostLocation location; |
| 18 | private final Set<IPv4> ips; |
| 19 | |
| 20 | public DefaultHostDescription(MACAddress mac, short vlan, |
| 21 | HostLocation loc, Set<IPv4> ips) { |
| 22 | this.mac = mac; |
| 23 | this.vlan = vlan; |
| 24 | this.location = loc; |
| 25 | this.ips = new HashSet<IPv4>(ips); |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public MACAddress hwAddress() { |
| 30 | return mac; |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public short vlan() { |
| 35 | return vlan; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public HostLocation location() { |
| 40 | return location; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public Set<IPv4> ipAddresses() { |
| 45 | return Collections.unmodifiableSet(ips); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public String toString() { |
| 50 | return toStringHelper(this) |
| 51 | .add("mac", mac) |
| 52 | .add("vlan", vlan) |
| 53 | .add("location", location) |
| 54 | .add("ipAddresses", ips) |
| 55 | .toString(); |
| 56 | } |
| 57 | |
| 58 | } |