2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onosproject.ovsdb.controller;
18 import static com.google.common.base.MoreObjects.toStringHelper;
20 import java.util.Objects;
23 import org.onlab.packet.IpAddress;
24 import org.onlab.packet.MacAddress;
27 * This class is default event subject that implements OvsdbEventSubject.
29 public class DefaultEventSubject implements OvsdbEventSubject {
30 private final MacAddress mac;
31 private final Set<IpAddress> ips;
32 private final OvsdbPortName portname;
33 private final OvsdbPortNumber portnumber;
34 private final OvsdbDatapathId dpid;
35 private final OvsdbPortType portType;
36 private final OvsdbIfaceId ifaceid;
39 * Creates an end-station event subject using the supplied information.
41 * @param mac host MAC address
42 * @param ips host MAC ips
43 * @param portname port name
44 * @param portnumber port number
45 * @param dpid ovs dpid
46 * @param portType port type
47 * @param ifaceid vm ifaceid
49 public DefaultEventSubject(MacAddress mac, Set<IpAddress> ips,
50 OvsdbPortName portname, OvsdbPortNumber portnumber, OvsdbDatapathId dpid,
51 OvsdbPortType portType, OvsdbIfaceId ifaceid) {
55 this.portname = portname;
56 this.portnumber = portnumber;
58 this.portType = portType;
59 this.ifaceid = ifaceid;
63 public MacAddress hwAddress() {
68 public Set<IpAddress> ipAddress() {
73 public OvsdbPortName portName() {
78 public OvsdbPortNumber portNumber() {
83 public OvsdbPortType portType() {
88 public OvsdbDatapathId dpid() {
93 public OvsdbIfaceId ifaceid() {
98 public int hashCode() {
99 return Objects.hash(mac, portname, portnumber, dpid, portType, ifaceid);
103 public boolean equals(Object obj) {
107 if (obj instanceof DefaultEventSubject) {
108 final DefaultEventSubject other = (DefaultEventSubject) obj;
109 return Objects.equals(this.mac, other.mac)
110 && Objects.equals(this.portname, other.portname)
111 && Objects.equals(this.portnumber, other.portnumber)
112 && Objects.equals(this.dpid, other.dpid)
113 && Objects.equals(this.portType, other.portType)
114 && Objects.equals(this.ifaceid, other.ifaceid);
120 public String toString() {
121 return toStringHelper(this).add("mac", mac).add("portname", portname)
122 .add("portnumber", portnumber).add("portType", portType)
123 .add("ipAddresses", ips).add("dpid", dpid).add("ifaceid", ifaceid)