package org.batfish.datamodel;

import org.batfish.common.Pair;
import org.batfish.datamodel.collections.NodeInterfacePair;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Edge extends Pair<NodeInterfacePair, NodeInterfacePair> {

   private static final long serialVersionUID = 1L;

   private static final String INT1_VAR = "int1";
   private static final String INT2_VAR = "int2";
   private static final String NODE1_VAR = "node1";
   private static final String NODE2_VAR = "node2";

   public Edge(NodeInterfacePair p1, NodeInterfacePair p2) {
      super(p1, p2);
   }

   @JsonCreator
   public Edge(@JsonProperty(NODE1_VAR) String node1,
         @JsonProperty(INT1_VAR) String int1,
         @JsonProperty(NODE2_VAR) String node2,
         @JsonProperty(INT2_VAR) String int2) {
      super(new NodeInterfacePair(node1, int1), new NodeInterfacePair(node2,
            int2));
   }

   @JsonProperty(INT1_VAR)
   public String getInt1() {
      return _first.getInterface();
   }

   @JsonProperty(INT2_VAR)
   public String getInt2() {
      return _second.getInterface();
   }

   @JsonIgnore
   public NodeInterfacePair getInterface1() {
      return _first;
   }

   @JsonIgnore
   public NodeInterfacePair getInterface2() {
      return _second;
   }

   @JsonProperty(NODE1_VAR)
   public String getNode1() {
      return _first.getHostname();
   }

   @JsonProperty(NODE2_VAR)
   public String getNode2() {
      return _second.getHostname();
   }

   @Override
   public String toString() {
      return getNode1() + ":" + getInt1() + ", " + getNode2() + ":" + getInt2();
   }

}

@@ -378,34 +378,42 @@
 nal 
-long serialVersionUID = 1L
+String INT1_VAR = %22node1interface%22
 ;%0A%0A 
@@ -445,25 +445,25 @@
 ring INT
-1
+2
 _VAR = %22
 int1%22;%0A 
@@ -458,15 +458,26 @@
  = %22
-int1
+node2interface
 %22;%0A
+%0A
    p
@@ -503,28 +503,29 @@
  String 
-INT2
+NODE1
 _VAR = %22
 int2%22;%0A 
@@ -520,15 +520,17 @@
  = %22
-int2
+node1
 %22;%0A
+%0A
    p
@@ -552,33 +552,33 @@
 inal String NODE
-1
+2
 _VAR = %22node1%22;%0A
@@ -573,20 +573,21 @@
  = %22node
-1
+2
 %22;%0A
+%0A
    priva
@@ -606,34 +606,34 @@
 nal 
-String NODE2_VAR = %22node2%22
+long serialVersionUID = 1L
 ;%0A%0A 

rename edge fields for easier reading