adding javadoc to intent classes: Action, FlowEntry, ForwardAction, Match
Change-Id: Ia7d6475adc7c88430deeb182e22604d766252c2c
diff --git a/src/main/java/net/onrc/onos/core/intent/Match.java b/src/main/java/net/onrc/onos/core/intent/Match.java
index d4e0ce2..0731395 100644
--- a/src/main/java/net/onrc/onos/core/intent/Match.java
+++ b/src/main/java/net/onrc/onos/core/intent/Match.java
@@ -5,14 +5,21 @@
import net.floodlightcontroller.util.MACAddress;
import net.onrc.onos.core.packet.Ethernet;
-//import net.onrc.onos.core.topology.Port;
-//import net.onrc.onos.core.topology.Switch;
import net.onrc.onos.core.util.FlowEntryMatch;
import net.onrc.onos.core.util.IPv4;
import net.onrc.onos.core.util.IPv4Net;
/**
- * @author Brian O'Connor <bocon@onlab.us>
+ * A class to represent the OpenFlow match.
+ * <p>
+ * At the moment, the supported match conditions are:
+ * <ul>
+ * <li>source port
+ * <li>source and destination MAC address
+ * <li>source and destination IP address
+ * </ul>
+ * <p>
+ * TODO: extend this object to allow more match conditions
*/
public class Match {
@@ -24,11 +31,29 @@
protected int dstIp;
protected long srcPort;
+ /**
+ * Constructor for Ethernet-based matches.
+ *
+ * @param sw switch's DPID
+ * @param srcPort source port on switch
+ * @param srcMac source Ethernet MAC address
+ * @param dstMac destination Ethernet MAC address
+ */
public Match(long sw, long srcPort,
MACAddress srcMac, MACAddress dstMac) {
this(sw, srcPort, srcMac, dstMac, ShortestPathIntent.EMPTYIPADDRESS, ShortestPathIntent.EMPTYIPADDRESS);
}
+ /**
+ * Generic constructor.
+ *
+ * @param sw switch's DPID
+ * @param srcPort source port on switch
+ * @param srcMac source Ethernet MAC address
+ * @param dstMac destination Ethernet MAC address
+ * @param srcIp source IP address
+ * @param dstIp destination IP address
+ */
public Match(long sw, long srcPort, MACAddress srcMac, MACAddress dstMac,
int srcIp, int dstIp) {
@@ -40,10 +65,16 @@
this.dstIp = dstIp;
}
+ /**
+ * Matches are equal if all object variables are equal.
+ *
+ * @return true if equal, false otherwise
+ */
@Override
public boolean equals(Object obj) {
if (obj instanceof Match) {
Match other = (Match) obj;
+ //TODO: we might consider excluding sw from this comparison
if (this.sw != other.sw) {
return false;
}
@@ -69,6 +100,11 @@
}
}
+ /**
+ * Converts the Match into a legacy FlowEntryMatch object.
+ *
+ * @return an equivalent FlowEntryMatch object
+ */
public FlowEntryMatch getFlowEntryMatch() {
FlowEntryMatch match = new FlowEntryMatch();
if (srcMac != null) {
@@ -93,13 +129,25 @@
return match;
}
+ /**
+ * Returns a String representation of this Match.
+ *
+ * @return the match as a String
+ */
@Override
public String toString() {
return "Sw:" + sw + " (" + srcPort + "," + srcMac + "," + dstMac + "," + srcIp + "," + dstIp + ")";
}
+ /**
+ * Generates hash using Objects.hash() to hash all object variables.
+ *
+ * @return hashcode
+ */
@Override
public int hashCode() {
+ //TODO: we might consider excluding sw from the hash function
+ // to make it easier to compare matches between switches
return Objects.hash(sw, srcPort, srcMac, dstMac, srcIp, dstIp);
}
}