Route reprogamming using group substitution during next hop movement

Change-Id: Idf8362dac522722ca67747e245bfd836e6ee6292
diff --git a/app/src/main/java/org/onosproject/segmentrouting/storekey/DestinationSetNextObjectiveStoreKey.java b/app/src/main/java/org/onosproject/segmentrouting/storekey/DestinationSetNextObjectiveStoreKey.java
index 9b6e621..0baa769 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/storekey/DestinationSetNextObjectiveStoreKey.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/storekey/DestinationSetNextObjectiveStoreKey.java
@@ -21,6 +21,8 @@
 import org.onosproject.net.DeviceId;
 import org.onosproject.segmentrouting.grouphandler.DestinationSet;
 
+import static com.google.common.base.MoreObjects.toStringHelper;
+
 /**
  * Key of Destination set next objective store.
  */
@@ -84,6 +86,9 @@
 
     @Override
     public String toString() {
-        return "Device: " + deviceId + " " + ds;
+        return toStringHelper(getClass())
+                .add("deviceId", deviceId)
+                .add("ds", ds)
+                .toString();
     }
 }
diff --git a/app/src/main/java/org/onosproject/segmentrouting/storekey/MacVlanNextObjectiveStoreKey.java b/app/src/main/java/org/onosproject/segmentrouting/storekey/MacVlanNextObjectiveStoreKey.java
new file mode 100644
index 0000000..4a1ab78
--- /dev/null
+++ b/app/src/main/java/org/onosproject/segmentrouting/storekey/MacVlanNextObjectiveStoreKey.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.segmentrouting.storekey;
+
+import org.onlab.packet.VlanId;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Key of Device/Vlan/MacAddr to NextObjective store.
+ */
+public class MacVlanNextObjectiveStoreKey {
+    private final DeviceId deviceId;
+    private final MacAddress macAddr;
+    private final VlanId vlanId;
+
+    /**
+     * Constructs the key of the next objective store.
+     *
+     * @param deviceId device ID
+     * @param macAddr mac of host
+     * @param vlanId vlan of host
+     */
+    public MacVlanNextObjectiveStoreKey(DeviceId deviceId, MacAddress macAddr, VlanId vlanId) {
+        this.deviceId = deviceId;
+        this.macAddr = macAddr;
+        this.vlanId = vlanId;
+    }
+
+    /**
+     * Gets device id in this MacVlanNextObjectiveStoreKey.
+     *
+     * @return device id
+     */
+    public DeviceId deviceId() {
+        return deviceId;
+    }
+
+    /**
+     * Gets vlan information in this MacVlanNextObjectiveStoreKey.
+     *
+     * @return vlan information
+     */
+    public VlanId vlanId() {
+        return vlanId;
+    }
+
+    /**
+     * Gets mac information in this MacVlanNextObjectiveStoreKey.
+     *
+     * @return mac information
+     */
+    public MacAddress macAddr() {
+        return macAddr;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof MacVlanNextObjectiveStoreKey)) {
+            return false;
+        }
+        MacVlanNextObjectiveStoreKey that =
+                (MacVlanNextObjectiveStoreKey) o;
+        return (Objects.equals(this.deviceId, that.deviceId) &&
+                Objects.equals(this.vlanId, that.vlanId) &&
+                Objects.equals(this.macAddr, that.macAddr));
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(deviceId, vlanId, macAddr);
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(getClass())
+                .add("deviceId", deviceId)
+                .add("vlanId", vlanId)
+                .add("macAddr", macAddr)
+                .toString();
+    }
+}
diff --git a/app/src/main/java/org/onosproject/segmentrouting/storekey/PortNextObjectiveStoreKey.java b/app/src/main/java/org/onosproject/segmentrouting/storekey/PortNextObjectiveStoreKey.java
index 9aa41db..1269bce 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/storekey/PortNextObjectiveStoreKey.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/storekey/PortNextObjectiveStoreKey.java
@@ -22,6 +22,8 @@
 
 import java.util.Objects;
 
+import static com.google.common.base.MoreObjects.toStringHelper;
+
 /**
  * Key of Device/Port to NextObjective store.
  *
@@ -111,8 +113,11 @@
 
     @Override
     public String toString() {
-        return "ConnectPoint: " + deviceId + "/" + portNum +
-                " Treatment: " + treatment +
-                " Meta: " + meta;
+        return toStringHelper(getClass())
+                .add("deviceId", deviceId)
+                .add("portNum", portNum)
+                .add("treatment", treatment)
+                .add("meta", meta)
+                .toString();
     }
 }
diff --git a/app/src/main/java/org/onosproject/segmentrouting/storekey/VlanNextObjectiveStoreKey.java b/app/src/main/java/org/onosproject/segmentrouting/storekey/VlanNextObjectiveStoreKey.java
index 5d9f2fd..55a95cd 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/storekey/VlanNextObjectiveStoreKey.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/storekey/VlanNextObjectiveStoreKey.java
@@ -21,6 +21,8 @@
 
 import java.util.Objects;
 
+import static com.google.common.base.MoreObjects.toStringHelper;
+
 /**
  * Key of VLAN to NextObjective store.
  */
@@ -79,6 +81,9 @@
 
     @Override
     public String toString() {
-        return "deviceId: " + deviceId + " vlanId: " + vlanId;
+        return toStringHelper(getClass())
+                .add("deviceId", deviceId)
+                .add("vlanId", vlanId)
+                .toString();
     }
 }