Refactor AtomixConsistentMap to use separate operations per method call for better performance and control over operation semantics.

Change-Id: I948c5c73d4ab38c9c2b20f8c80ba01548f95dda6
diff --git a/core/api/src/main/java/org/onosproject/store/service/MapEvent.java b/core/api/src/main/java/org/onosproject/store/service/MapEvent.java
index 818e749..2e8aa61 100644
--- a/core/api/src/main/java/org/onosproject/store/service/MapEvent.java
+++ b/core/api/src/main/java/org/onosproject/store/service/MapEvent.java
@@ -62,12 +62,25 @@
      * @param previousValue value that was replaced
      */
     public MapEvent(String name, K key, Versioned<V> currentValue, Versioned<V> previousValue) {
+        this(currentValue != null ? previousValue != null ? Type.UPDATE : Type.INSERT : Type.REMOVE,
+                name, key, currentValue, previousValue);
+    }
+
+    /**
+     * Creates a new event object.
+     *
+     * @param type event type
+     * @param name map name
+     * @param key key the event concerns
+     * @param currentValue new value key is mapped to
+     * @param previousValue value that was replaced
+     */
+    public MapEvent(Type type, String name, K key, Versioned<V> currentValue, Versioned<V> previousValue) {
+        this.type = type;
         this.name = name;
         this.key = key;
         this.newValue = currentValue;
         this.oldValue = previousValue;
-        this.type = currentValue != null ?
-                    previousValue != null ? Type.UPDATE : Type.INSERT : Type.REMOVE;
     }
 
     /**
diff --git a/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java b/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java
index 698498e..10311a9 100644
--- a/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java
+++ b/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java
@@ -30,11 +30,14 @@
     private final Versioned<Integer> vStatsNew = new Versioned<>(2, 2);
     private final Versioned<Integer> vStatsOld = new Versioned<>(1, 1);
 
-    private final MapEvent<String, Integer> stats1 = new MapEvent<>("a", "1", vStatsNew, null);
+    private final MapEvent<String, Integer> stats1 =
+            new MapEvent<>(MapEvent.Type.INSERT, "a", "1", vStatsNew, null);
 
-    private final MapEvent<String, Integer> stats2 = new MapEvent<>("a", "1", null, vStatsOld);
+    private final MapEvent<String, Integer> stats2 =
+            new MapEvent<>(MapEvent.Type.REMOVE, "a", "1", null, vStatsOld);
 
-    private final MapEvent<String, Integer> stats3 = new MapEvent<>("a", "1", vStatsNew, vStatsOld);
+    private final MapEvent<String, Integer> stats3 =
+            new MapEvent<>(MapEvent.Type.UPDATE, "a", "1", vStatsNew, vStatsOld);
 
     /**
      * Tests the creation of the MapEvent object.