[ONOS-7547] Implement support for backwards/forward compatibility of ConsistentMap values on read

Change-Id: Ifffb6a883ec4ee6aa5587da58a51c1e90694e5ea
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java
index c576375..1691086 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java
@@ -38,8 +38,8 @@
     private boolean meteringDisabled = false;
     private boolean readOnly = false;
     private boolean relaxedReadConsistency = false;
-    private int revisionNumber = 1;
-    private RevisionType revisionType = RevisionType.NONE;
+    private Version version;
+    private RevisionType revisionType;
 
     public DistributedPrimitiveOptions(DistributedPrimitive.Type type) {
         this.type = type;
@@ -85,17 +85,7 @@
      * @return this builder
      */
     public O withVersion(Version version) {
-        return withRevisionNumber(version.toInt());
-    }
-
-    /**
-     * Sets the primitive revision.
-     *
-     * @param revision the primitive revision
-     * @return this builder
-     */
-    public O withRevisionNumber(int revision) {
-        this.revisionNumber = revision;
+        this.version = version;
         return (O) this;
     }
 
@@ -212,12 +202,12 @@
     }
 
     /**
-     * Returns the primitive revision number.
+     * Returns the primitive version.
      *
-     * @return the primitive revision number
+     * @return the primitive version
      */
-    public final int revision() {
-        return revisionNumber;
+    public final Version version() {
+        return version;
     }
 
     /**
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java
index 587789d..4dacab8 100644
--- a/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.store.service;
 
+import java.util.function.BiFunction;
+
 import org.onosproject.store.primitives.DistributedPrimitiveOptions;
 
 /**
@@ -28,6 +30,7 @@
 
     private boolean nullValues = false;
     private boolean purgeOnUninstall = false;
+    protected BiFunction<V, org.onosproject.core.Version, V> compatibilityFunction;
 
     public ConsistentMapOptions() {
         super(DistributedPrimitive.Type.CONSISTENT_MAP);
@@ -54,6 +57,19 @@
     }
 
     /**
+     * Sets a compatibility function on the map.
+     *
+     * @param compatibilityFunction the compatibility function
+     * @return the consistent map builder
+     */
+    @SuppressWarnings("unchecked")
+    public O withCompatibilityFunction(
+        BiFunction<V, org.onosproject.core.Version, V> compatibilityFunction) {
+        this.compatibilityFunction = compatibilityFunction;
+        return (O) this;
+    }
+
+    /**
      * Returns whether null values are supported by the map.
      *
      * @return {@code true} if null values are supported; {@code false} otherwise