Make Pair class immutable when user supplies immutable objects

- Make fields private
- Add getters

Change-Id: I4bdc63316e21a88f9026cd42e424bf94873d02bb
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
index 05510f6..68da549 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
@@ -644,7 +644,7 @@
             Collection<Pair<IOFSwitch, FlowEntry>> entries, MsgPriority priority) {
 
         for (Pair<IOFSwitch, FlowEntry> entry : entries) {
-            add(entry.first, entry.second, priority);
+            add(entry.getFirst(), entry.getSecond(), priority);
         }
     }
 
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/PlanInstallRuntime.java b/src/main/java/net/onrc/onos/core/intent/runtime/PlanInstallRuntime.java
index ca7fcaa..c92599c 100644
--- a/src/main/java/net/onrc/onos/core/intent/runtime/PlanInstallRuntime.java
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/PlanInstallRuntime.java
@@ -135,8 +135,8 @@
                 barriers.add(new Pair<>(sw, pusher.barrierAsync(sw)));
             }
             for (Pair<IOFSwitch, OFMessageFuture<OFBarrierReply>> pair : barriers) {
-                IOFSwitch sw = pair.first;
-                OFMessageFuture<OFBarrierReply> future = pair.second;
+                IOFSwitch sw = pair.getFirst();
+                OFMessageFuture<OFBarrierReply> future = pair.getSecond();
                 try {
                     future.get();
                 } catch (InterruptedException | ExecutionException e) {
diff --git a/src/main/java/net/onrc/onos/core/util/Pair.java b/src/main/java/net/onrc/onos/core/util/Pair.java
index 6fe8101..c5ab775 100644
--- a/src/main/java/net/onrc/onos/core/util/Pair.java
+++ b/src/main/java/net/onrc/onos/core/util/Pair.java
@@ -4,10 +4,16 @@
 
 /**
  * A generic class representing a pair of two values.
+ *
+ * If a user supplies immutable objects, the pair become immutable.
+ * Otherwise, the pair become mutable.
+ *
+ * @param <F> the type of the first value
+ * @param <S> the type type of the second value
  */
 public class Pair<F, S> {
-    public F first;        // The first value in the pair
-    public S second;        // The second value in the pair
+    private final F first;        // The first value in the pair
+    private final S second;       // The second value in the pair
 
     /**
      * Constructor for a pair of two values.
@@ -20,6 +26,24 @@
         this.second = second;
     }
 
+    /**
+     * Get the first value of the Pair.
+     *
+     * @return the first value of the Pair.
+     */
+    public F getFirst() {
+        return first;
+    }
+
+    /**
+     * Get the second value of the Pair.
+     *
+     * @return the second value of the Pair.
+     */
+    public S getSecond() {
+        return second;
+    }
+
     @Override
     public String toString() {
         return String.format("<%s, %s>", first, second);