Improve MapDB read performance by using cached hash code

With existing implementation, the hashcode of LispEidRecord
should always be recaluclated when we lookup MapDB.
If we have very large number of entries stored in a HashMap,
the performance becomes very poor.
With this cached hashcode implementation, we can improve
the MapDB lookup performance.

Change-Id: Ie193e0b96b2bdc470e52f6f1de4f341527e0507d
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java
index 41d7583..5a8fd6c 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java
@@ -35,6 +35,9 @@
     private final byte maskLength;
     private final LispAfiAddress prefix;
 
+    // Cache the hash code for the string, default to 0
+    private final int hash;
+
     /**
      * Initializes LispEidRecord with mask length and EID prefix.
      *
@@ -47,6 +50,7 @@
         checkNotNull(prefix, "Must specify an address prefix");
 
         this.prefix = prefix;
+        this.hash = 31 * 17 + Objects.hashCode(maskLength, prefix);
     }
 
     /**
@@ -90,7 +94,7 @@
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(maskLength, prefix);
+        return hash;
     }
 
     /**