summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
diff options
context:
space:
mode:
authorAshlee Young <ashlee@wildernessvoice.com>2015-11-11 14:39:51 -0800
committerAshlee Young <ashlee@wildernessvoice.com>2015-11-11 14:40:00 -0800
commitbaac58c7c50e6f89eb0520e3f5b0e83a69839bd3 (patch)
tree9c5a149ee6cdf345fed7dfe8c97fcaac8959a70d /framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
parent8f92448e4f2f5d9c98036097bdabd1c40166908a (diff)
Updating onos src to commit id ec0425c18cbe49d368c600160f033acf9fe344ca
Change-Id: Iec2815bf7771080f25272842b852bd9d33f908ff Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
index 98329df0..58ac0bb8 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
@@ -15,8 +15,12 @@
*/
package org.onosproject.net.host;
+import org.joda.time.LocalDateTime;
import org.onosproject.event.AbstractEvent;
import org.onosproject.net.Host;
+import org.onosproject.net.HostLocation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Describes end-station host event.
@@ -48,6 +52,8 @@ public class HostEvent extends AbstractEvent<HostEvent.Type, Host> {
HOST_MOVED
}
+ private HostLocation prevLocation;
+
/**
* Creates an event of a given type and for the specified host and the
* current time.
@@ -70,4 +76,35 @@ public class HostEvent extends AbstractEvent<HostEvent.Type, Host> {
super(type, host, time);
}
+ /**
+ * Creates an event with HOST_MOVED type along with the previous location
+ * of the host.
+ *
+ * @param host event host subject
+ * @param prevLocation previous location of the host
+ */
+ public HostEvent(Host host, HostLocation prevLocation) {
+ super(Type.HOST_MOVED, host);
+ this.prevLocation = prevLocation;
+ }
+
+ /**
+ * Gets the previous location information in this host event.
+ *
+ * @return the previous location, or null if previous location is not
+ * specified.
+ */
+ public HostLocation prevLocation() {
+ return this.prevLocation;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("time", new LocalDateTime(time()))
+ .add("type", type())
+ .add("subject", subject())
+ .add("prevLocation", prevLocation())
+ .toString();
+ }
}