diff --git a/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java b/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
index 3efc018..a7f6bd2 100644
--- a/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
+++ b/web/api/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
@@ -34,6 +34,7 @@
 import static org.onlab.junit.TestUtils.getField;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
+import static org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion;
 
 /**
  * Unit tests for criterion codec.
@@ -81,8 +82,7 @@
     public void matchInPortTest() {
         Criterion criterion = Criteria.matchInPort(port);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("port").asLong(), is(port.toLong()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -92,8 +92,7 @@
     public void matchInPhyPortTest() {
         Criterion criterion = Criteria.matchInPhyPort(port);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("port").asLong(), is(port.toLong()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -103,8 +102,7 @@
     public void matchMetadataTest() {
         Criterion criterion = Criteria.matchMetadata(0xabcdL);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("metadata").asLong(), is(0xabcdL));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -114,8 +112,7 @@
     public void matchEthDstTest() {
         Criterion criterion = Criteria.matchEthDst(mac1);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("mac").asText(), is(mac1.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -125,8 +122,7 @@
     public void matchEthSrcTest() {
         Criterion criterion = Criteria.matchEthSrc(mac1);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("mac").asText(), is(mac1.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -136,8 +132,7 @@
     public void matchEthTypeTest() {
         Criterion criterion = Criteria.matchEthType((short) 0x8844);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ethType").asInt(), is(0x8844));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -147,8 +142,7 @@
     public void matchVlanIdTest() {
         Criterion criterion = Criteria.matchVlanId(VlanId.ANY);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat((short) result.get("vlanId").asInt(), is(VlanId.ANY.toShort()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -158,8 +152,7 @@
     public void matchVlanPcpTest() {
         Criterion criterion = Criteria.matchVlanPcp((byte) 7);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("priority").asInt(), is(7));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -169,8 +162,7 @@
     public void matchIPDscpTest() {
         Criterion criterion = Criteria.matchIPDscp((byte) 63);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ipDscp").asInt(), is(63));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -180,8 +172,7 @@
     public void matchIPEcnTest() {
         Criterion criterion = Criteria.matchIPEcn((byte) 7);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ipEcn").asInt(), is(7));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -191,8 +182,7 @@
     public void matchIPProtocolTest() {
         Criterion criterion = Criteria.matchIPProtocol((byte) 250);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("protocol").asInt(), is(250));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -202,8 +192,7 @@
     public void matchIPSrcTest() {
         Criterion criterion = Criteria.matchIPSrc(ipPrefix4);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ip").asText(), is(ipPrefix4.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -213,8 +202,7 @@
     public void matchIPDstTest() {
         Criterion criterion = Criteria.matchIPDst(ipPrefix4);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ip").asText(), is(ipPrefix4.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -224,8 +212,7 @@
     public void matchTcpSrcTest() {
         Criterion criterion = Criteria.matchTcpSrc((short) 40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("tcpPort").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -235,8 +222,7 @@
     public void matchTcpDstTest() {
         Criterion criterion = Criteria.matchTcpDst((short) 40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("tcpPort").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -244,10 +230,9 @@
      */
     @Test
     public void matchUdpSrcTest() {
-        Criterion criterion = Criteria.matchUdpSrc((short) 40000);
+        Criterion criterion = Criteria.matchUdpSrc(40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("udpPort").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -255,10 +240,9 @@
      */
     @Test
     public void matchUdpDstTest() {
-        Criterion criterion = Criteria.matchUdpDst((short) 40000);
+        Criterion criterion = Criteria.matchUdpDst(40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("udpPort").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -266,10 +250,9 @@
      */
     @Test
     public void matchSctpSrcTest() {
-        Criterion criterion = Criteria.matchSctpSrc((short) 40000);
+        Criterion criterion = Criteria.matchSctpSrc(40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("sctpPort").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -277,10 +260,9 @@
      */
     @Test
     public void matchSctpDstTest() {
-        Criterion criterion = Criteria.matchSctpDst((short) 40000);
+        Criterion criterion = Criteria.matchSctpDst(40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("sctpPort").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -290,8 +272,7 @@
     public void matchIcmpTypeTest() {
         Criterion criterion = Criteria.matchIcmpType((byte) 250);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("icmpType").asInt(), is(250));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -301,8 +282,7 @@
     public void matchIcmpCodeTest() {
         Criterion criterion = Criteria.matchIcmpCode((byte) 250);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("icmpCode").asInt(), is(250));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -312,8 +292,7 @@
     public void matchIPv6SrcTest() {
         Criterion criterion = Criteria.matchIPv6Src(ipPrefix6);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ip").asText(), is(ipPrefix6.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -323,8 +302,7 @@
     public void matchIPv6DstTest() {
         Criterion criterion = Criteria.matchIPv6Dst(ipPrefix6);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("ip").asText(), is(ipPrefix6.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -334,8 +312,7 @@
     public void matchIPv6FlowLabelTest() {
         Criterion criterion = Criteria.matchIPv6FlowLabel(0xffffe);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("flowLabel").asInt(), is(0xffffe));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -345,8 +322,7 @@
     public void matchIcmpv6TypeTest() {
         Criterion criterion = Criteria.matchIcmpv6Type((byte) 250);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("icmpv6Type").asInt(), is(250));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -356,8 +332,7 @@
     public void matchIcmpv6CodeTest() {
         Criterion criterion = Criteria.matchIcmpv6Code((byte) 250);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("icmpv6Code").asInt(), is(250));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -369,8 +344,7 @@
                 Criteria.matchIPv6NDTargetAddress(
                         Ip6Address.valueOf("1111:2222::"));
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("targetAddress").asText(), is("1111:2222::"));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -380,8 +354,7 @@
     public void matchIPv6NDSourceLinkLayerAddressTest() {
         Criterion criterion = Criteria.matchIPv6NDSourceLinkLayerAddress(mac1);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("mac").asText(), is(mac1.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -391,8 +364,7 @@
     public void matchIPv6NDTargetLinkLayerAddressTest() {
         Criterion criterion = Criteria.matchIPv6NDTargetLinkLayerAddress(mac1);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("mac").asText(), is(mac1.toString()));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -402,8 +374,7 @@
     public void matchMplsLabelTest() {
         Criterion criterion = Criteria.matchMplsLabel(0xffffe);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("label").asInt(), is(0xffffe));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -423,8 +394,8 @@
             Criterion.IPv6ExthdrFlags.UNSEQ.getValue();
         Criterion criterion = Criteria.matchIPv6ExthdrFlags(exthdrFlags);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("exthdrFlags").asInt(), is(exthdrFlags));
+
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -434,8 +405,7 @@
     public void matchLambdaTest() {
         Criterion criterion = Criteria.matchLambda((short) 40000);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("lambda").asInt(), is(40000));
+        assertThat(result, matchesCriterion(criterion));
     }
 
     /**
@@ -445,8 +415,7 @@
     public void matchOpticalSignalTypeTest() {
         Criterion criterion = Criteria.matchOpticalSignalType((byte) 250);
         ObjectNode result = criterionCodec.encode(criterion, context);
-        assertThat(result.get("type").textValue(), is(criterion.type().toString()));
-        assertThat(result.get("signalType").asInt(), is(250));
+        assertThat(result, matchesCriterion(criterion));
     }
 
 }
diff --git a/web/api/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java b/web/api/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
index 0ffeed4..3c5f119 100644
--- a/web/api/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
+++ b/web/api/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
@@ -25,18 +25,442 @@
 /**
  * Hamcrest matcher for criterion objects.
  */
-public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> {
+public final class CriterionJsonMatcher extends
+        TypeSafeDiagnosingMatcher<JsonNode> {
 
     final Criterion criterion;
+    Description description;
+    JsonNode jsonCriterion;
 
+    /**
+     * Constructs a matcher object.
+     *
+     * @param criterionValue criterion to match
+     */
     private CriterionJsonMatcher(Criterion criterionValue) {
         criterion = criterionValue;
     }
 
-    // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES
+    /**
+     * Factory to allocate an criterion matcher.
+     *
+     * @param criterion criterion object we are looking for
+     * @return matcher
+     */
+    public static CriterionJsonMatcher matchesCriterion(Criterion criterion) {
+        return new CriterionJsonMatcher(criterion);
+    }
+
+    /**
+     * Matches a port criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.PortCriterion criterion) {
+        final long port = criterion.port().toLong();
+        final long jsonPort = jsonCriterion.get("port").asLong();
+        if (port != jsonPort) {
+            description.appendText("port was " + Long.toString(jsonPort));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches a metadata criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.MetadataCriterion criterion) {
+        final long metadata = criterion.metadata();
+        final long jsonMetadata = jsonCriterion.get("metadata").asLong();
+        if (metadata != jsonMetadata) {
+            description.appendText("metadata was "
+                    + Long.toString(jsonMetadata));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an eth criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.EthCriterion criterion) {
+        final String mac = criterion.mac().toString();
+        final String jsonMac = jsonCriterion.get("mac").textValue();
+        if (!mac.equals(jsonMac)) {
+            description.appendText("mac was " + jsonMac);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an eth type criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.EthTypeCriterion criterion) {
+        final int ethType = criterion.ethType();
+        final int jsonEthType = jsonCriterion.get("ethType").intValue();
+        if (ethType != jsonEthType) {
+            description.appendText("ethType was "
+                    + Integer.toString(jsonEthType));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches a VLAN ID criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.VlanIdCriterion criterion) {
+        final short vlanId = criterion.vlanId().toShort();
+        final short jsonVlanId = jsonCriterion.get("vlanId").shortValue();
+        if (vlanId != jsonVlanId) {
+            description.appendText("vlanId was " + Short.toString(jsonVlanId));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches a VLAN PCP criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.VlanPcpCriterion criterion) {
+        final byte priority = criterion.priority();
+        final byte jsonPriority =
+                (byte) jsonCriterion.get("priority").shortValue();
+        if (priority != jsonPriority) {
+            description.appendText("priority was " + Byte.toString(jsonPriority));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IP DSCP criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPDscpCriterion criterion) {
+        final byte ipDscp = criterion.ipDscp();
+        final byte jsonIpDscp = (byte) jsonCriterion.get("ipDscp").shortValue();
+        if (ipDscp != jsonIpDscp) {
+            description.appendText("IP DSCP was " + Byte.toString(jsonIpDscp));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IP ECN criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPEcnCriterion criterion) {
+        final byte ipEcn = criterion.ipEcn();
+        final byte jsonIpEcn = (byte) jsonCriterion.get("ipEcn").shortValue();
+        if (ipEcn != jsonIpEcn) {
+            description.appendText("IP ECN was " + Byte.toString(jsonIpEcn));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IP protocol criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPProtocolCriterion criterion) {
+        final short protocol = criterion.protocol();
+        final short jsonProtocol = jsonCriterion.get("protocol").shortValue();
+        if (protocol != jsonProtocol) {
+            description.appendText("protocol was "
+                    + Short.toString(jsonProtocol));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IP address criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPCriterion criterion) {
+        final String ip = criterion.ip().toString();
+        final String jsonIp = jsonCriterion.get("ip").textValue();
+        if (!ip.equals(jsonIp)) {
+            description.appendText("ip was " + jsonIp);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches a TCP port criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.TcpPortCriterion criterion) {
+        final int tcpPort = criterion.tcpPort();
+        final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue();
+        if (tcpPort != jsonTcpPort) {
+            description.appendText("tcp port was "
+                    + Integer.toString(jsonTcpPort));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches a UDP port criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.UdpPortCriterion criterion) {
+        final int udpPort = criterion.udpPort();
+        final int jsonUdpPort = jsonCriterion.get("udpPort").intValue();
+        if (udpPort != jsonUdpPort) {
+            description.appendText("udp port was "
+                    + Integer.toString(jsonUdpPort));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an SCTP port criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.SctpPortCriterion criterion) {
+        final int sctpPort = criterion.sctpPort();
+        final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue();
+        if (sctpPort != jsonSctpPort) {
+            description.appendText("sctp port was "
+                    + Integer.toString(jsonSctpPort));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an ICMP type criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IcmpTypeCriterion criterion) {
+        final short icmpType = criterion.icmpType();
+        final short jsonIcmpType = jsonCriterion.get("icmpType").shortValue();
+        if (icmpType != jsonIcmpType) {
+            description.appendText("icmp type was "
+                    + Short.toString(jsonIcmpType));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an ICMP code criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IcmpCodeCriterion criterion) {
+        final short icmpCode = criterion.icmpCode();
+        final short jsonIcmpCode = jsonCriterion.get("icmpCode").shortValue();
+        if (icmpCode != jsonIcmpCode) {
+            description.appendText("icmp code was "
+                    + Short.toString(jsonIcmpCode));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IPV6 flow label criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPv6FlowLabelCriterion criterion) {
+        final int flowLabel = criterion.flowLabel();
+        final int jsonFlowLabel = jsonCriterion.get("flowLabel").intValue();
+        if (flowLabel != jsonFlowLabel) {
+            description.appendText("IPv6 flow label was "
+                    + Integer.toString(jsonFlowLabel));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an ICMP V6 type criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.Icmpv6TypeCriterion criterion) {
+        final short icmpv6Type = criterion.icmpv6Type();
+        final short jsonIcmpv6Type =
+                jsonCriterion.get("icmpv6Type").shortValue();
+        if (icmpv6Type != jsonIcmpv6Type) {
+            description.appendText("icmpv6 type was "
+                    + Short.toString(jsonIcmpv6Type));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IPV6 code criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.Icmpv6CodeCriterion criterion) {
+        final short icmpv6Code = criterion.icmpv6Code();
+        final short jsonIcmpv6Code =
+                jsonCriterion.get("icmpv6Code").shortValue();
+        if (icmpv6Code != jsonIcmpv6Code) {
+            description.appendText("icmpv6 code was "
+                    + Short.toString(jsonIcmpv6Code));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IPV6 ND target criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPv6NDTargetAddressCriterion criterion) {
+        final String targetAddress =
+                criterion.targetAddress().toString();
+        final String jsonTargetAddress =
+                jsonCriterion.get("targetAddress").textValue();
+        if (!targetAddress.equals(jsonTargetAddress)) {
+            description.appendText("target address was " +
+                    jsonTargetAddress);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IPV6 ND link layer criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPv6NDLinkLayerAddressCriterion criterion) {
+        final String llAddress =
+                criterion.mac().toString();
+        final String jsonLlAddress =
+                jsonCriterion.get("mac").textValue();
+        if (!llAddress.equals(jsonLlAddress)) {
+            description.appendText("mac was " + jsonLlAddress);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an MPLS label criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.MplsCriterion criterion) {
+        final int label = criterion.label();
+        final int jsonLabel = jsonCriterion.get("label").intValue();
+        if (label != jsonLabel) {
+            description.appendText("label was " + Integer.toString(jsonLabel));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an IPV6 exthdr criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.IPv6ExthdrFlagsCriterion criterion) {
+        final int exthdrFlags = criterion.exthdrFlags();
+        final int jsonExthdrFlags =
+                jsonCriterion.get("exthdrFlags").intValue();
+        if (exthdrFlags != jsonExthdrFlags) {
+            description.appendText("exthdrFlags was "
+                    + Long.toHexString(jsonExthdrFlags));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches a lambda criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.LambdaCriterion criterion) {
+        final int lambda = criterion.lambda();
+        final int jsonLambda = jsonCriterion.get("lambda").intValue();
+        if (lambda != jsonLambda) {
+            description.appendText("lambda was " + Integer.toString(lambda));
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Matches an optical signal type criterion object.
+     *
+     * @param criterion criterion to match
+     * @return true if the JSON matches the criterion, false otherwise.
+     */
+    private boolean matchCriterion(Criteria.OpticalSignalTypeCriterion criterion) {
+        final short signalType = criterion.signalType();
+        final short jsonSignalType = jsonCriterion.get("signalType").shortValue();
+        if (signalType != jsonSignalType) {
+            description.appendText("signal type was " + Short.toString(signalType));
+            return false;
+        }
+        return true;
+    }
+
     @Override
     public boolean matchesSafely(JsonNode jsonCriterion,
                                  Description description) {
+        this.description = description;
+        this.jsonCriterion = jsonCriterion;
         final String type = criterion.type().name();
         final String jsonType = jsonCriterion.get("type").asText();
         if (!type.equals(jsonType)) {
@@ -48,285 +472,88 @@
 
             case IN_PORT:
             case IN_PHY_PORT:
-                final Criteria.PortCriterion portCriterion =
-                        (Criteria.PortCriterion) criterion;
-                final long port = portCriterion.port().toLong();
-                final long jsonPort = jsonCriterion.get("port").asLong();
-                if (port != jsonPort) {
-                    description.appendText("port was " + Long.toString(jsonPort));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.PortCriterion) criterion);
 
             case METADATA:
-                final Criteria.MetadataCriterion metadataCriterion =
-                        (Criteria.MetadataCriterion) criterion;
-                final long metadata = metadataCriterion.metadata();
-                final long jsonMetadata = jsonCriterion.get("metadata").asLong();
-                if (metadata != jsonMetadata) {
-                    description.appendText("metadata was " + Long.toString(jsonMetadata));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.MetadataCriterion) criterion);
 
             case ETH_DST:
             case ETH_SRC:
-                final Criteria.EthCriterion ethCriterion =
-                    (Criteria.EthCriterion) criterion;
-                final String mac = ethCriterion.mac().toString();
-                final String jsonMac = jsonCriterion.get("mac").textValue();
-                if (!mac.equals(jsonMac)) {
-                    description.appendText("mac was " + jsonMac);
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.EthCriterion) criterion);
 
             case ETH_TYPE:
-                final Criteria.EthTypeCriterion ethTypeCriterion =
-                        (Criteria.EthTypeCriterion) criterion;
-                final String ethType =
-                    Long.toHexString(ethTypeCriterion.ethType());
-                final String jsonEthType = jsonCriterion.get("ethType").textValue();
-                if (!ethType.equals(jsonEthType)) {
-                    description.appendText("ethType was " + jsonEthType);
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.EthTypeCriterion) criterion);
 
             case VLAN_VID:
-                final Criteria.VlanIdCriterion vlanIdCriterion =
-                        (Criteria.VlanIdCriterion) criterion;
-                final short vlanId = vlanIdCriterion.vlanId().toShort();
-                final short jsonVlanId = jsonCriterion.get("vlanId").shortValue();
-                if (vlanId != jsonVlanId) {
-                    description.appendText("vlanId was " + Short.toString(jsonVlanId));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.VlanIdCriterion) criterion);
 
             case VLAN_PCP:
-                final Criteria.VlanPcpCriterion vlanPcpCriterion =
-                        (Criteria.VlanPcpCriterion) criterion;
-                final byte priority = vlanPcpCriterion.priority();
-                final byte jsonPriority = (byte) jsonCriterion.get("priority").shortValue();
-                if (priority != jsonPriority) {
-                    description.appendText("priority was " + Byte.toString(jsonPriority));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.VlanPcpCriterion) criterion);
 
             case IP_DSCP:
-                final Criteria.IPDscpCriterion ipDscpCriterion =
-                        (Criteria.IPDscpCriterion) criterion;
-                final byte ipDscp = ipDscpCriterion.ipDscp();
-                final byte jsonIpDscp = (byte) jsonCriterion.get("ipDscp").shortValue();
-                if (ipDscp != jsonIpDscp) {
-                    description.appendText("IP DSCP was " + Byte.toString(jsonIpDscp));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IPDscpCriterion) criterion);
 
             case IP_ECN:
-                final Criteria.IPEcnCriterion ipEcnCriterion =
-                        (Criteria.IPEcnCriterion) criterion;
-                final byte ipEcn = ipEcnCriterion.ipEcn();
-                final byte jsonIpEcn = (byte) jsonCriterion.get("ipEcn").shortValue();
-                if (ipEcn != jsonIpEcn) {
-                    description.appendText("IP ECN was " + Byte.toString(jsonIpEcn));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IPEcnCriterion) criterion);
 
             case IP_PROTO:
-                final Criteria.IPProtocolCriterion iPProtocolCriterion =
-                        (Criteria.IPProtocolCriterion) criterion;
-                final short protocol = iPProtocolCriterion.protocol();
-                final short jsonProtocol = jsonCriterion.get("protocol").shortValue();
-                if (protocol != jsonProtocol) {
-                    description.appendText("protocol was " + Short.toString(jsonProtocol));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IPProtocolCriterion) criterion);
 
             case IPV4_SRC:
             case IPV4_DST:
             case IPV6_SRC:
             case IPV6_DST:
-                final Criteria.IPCriterion ipCriterion =
-                    (Criteria.IPCriterion) criterion;
-                final String ip = ipCriterion.ip().toString();
-                final String jsonIp = jsonCriterion.get("ip").textValue();
-                if (!ip.equals(jsonIp)) {
-                    description.appendText("ip was " + jsonIp);
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IPCriterion) criterion);
 
             case TCP_SRC:
             case TCP_DST:
-                final Criteria.TcpPortCriterion tcpPortCriterion =
-                        (Criteria.TcpPortCriterion) criterion;
-                final int tcpPort = tcpPortCriterion.tcpPort();
-                final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue();
-                if (tcpPort != jsonTcpPort) {
-                    description.appendText("tcp port was " + Integer.toString(jsonTcpPort));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.TcpPortCriterion) criterion);
 
             case UDP_SRC:
             case UDP_DST:
-                final Criteria.UdpPortCriterion udpPortCriterion =
-                        (Criteria.UdpPortCriterion) criterion;
-                final int udpPort = udpPortCriterion.udpPort();
-                final int jsonUdpPort = jsonCriterion.get("udpPort").intValue();
-                if (udpPort != jsonUdpPort) {
-                    description.appendText("udp port was " + Integer.toString(jsonUdpPort));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.UdpPortCriterion) criterion);
 
             case SCTP_SRC:
             case SCTP_DST:
-                final Criteria.SctpPortCriterion sctpPortCriterion =
-                        (Criteria.SctpPortCriterion) criterion;
-                final int sctpPort = sctpPortCriterion.sctpPort();
-                final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue();
-                if (sctpPort != jsonSctpPort) {
-                    description.appendText("sctp port was " + Integer.toString(jsonSctpPort));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.SctpPortCriterion) criterion);
 
             case ICMPV4_TYPE:
-                final Criteria.IcmpTypeCriterion icmpTypeCriterion =
-                        (Criteria.IcmpTypeCriterion) criterion;
-                final short icmpType = icmpTypeCriterion.icmpType();
-                final short jsonIcmpType = jsonCriterion.get("icmpType").shortValue();
-                if (icmpType != jsonIcmpType) {
-                    description.appendText("icmp type was " + Short.toString(jsonIcmpType));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IcmpTypeCriterion) criterion);
 
             case ICMPV4_CODE:
-                final Criteria.IcmpCodeCriterion icmpCodeCriterion =
-                        (Criteria.IcmpCodeCriterion) criterion;
-                final short icmpCode = icmpCodeCriterion.icmpCode();
-                final short jsonIcmpCode = jsonCriterion.get("icmpCode").shortValue();
-                if (icmpCode != jsonIcmpCode) {
-                    description.appendText("icmp code was " + Short.toString(jsonIcmpCode));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IcmpCodeCriterion) criterion);
 
             case IPV6_FLABEL:
-                final Criteria.IPv6FlowLabelCriterion ipv6FlowLabelCriterion =
-                        (Criteria.IPv6FlowLabelCriterion) criterion;
-                final int flowLabel = ipv6FlowLabelCriterion.flowLabel();
-                final int jsonFlowLabel = jsonCriterion.get("flowLabel").intValue();
-                if (flowLabel != jsonFlowLabel) {
-                    description.appendText("IPv6 flow label was " + Integer.toString(jsonFlowLabel));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.IPv6FlowLabelCriterion) criterion);
 
             case ICMPV6_TYPE:
-                final Criteria.Icmpv6TypeCriterion icmpv6TypeCriterion =
-                        (Criteria.Icmpv6TypeCriterion) criterion;
-                final short icmpv6Type = icmpv6TypeCriterion.icmpv6Type();
-                final short jsonIcmpv6Type = jsonCriterion.get("icmpv6Type").shortValue();
-                if (icmpv6Type != jsonIcmpv6Type) {
-                    description.appendText("icmpv6 type was " + Short.toString(jsonIcmpv6Type));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.Icmpv6TypeCriterion) criterion);
 
             case ICMPV6_CODE:
-                final Criteria.Icmpv6CodeCriterion icmpv6CodeCriterion =
-                        (Criteria.Icmpv6CodeCriterion) criterion;
-                final short icmpv6Code = icmpv6CodeCriterion.icmpv6Code();
-                final short jsonIcmpv6Code = jsonCriterion.get("icmpv6Code").shortValue();
-                if (icmpv6Code != jsonIcmpv6Code) {
-                    description.appendText("icmpv6 code was " + Short.toString(jsonIcmpv6Code));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.Icmpv6CodeCriterion) criterion);
 
             case IPV6_ND_TARGET:
-                final Criteria.IPv6NDTargetAddressCriterion
-                    ipv6NDTargetAddressCriterion =
-                        (Criteria.IPv6NDTargetAddressCriterion) criterion;
-                final String targetAddress =
-                    ipv6NDTargetAddressCriterion.targetAddress().toString();
-                final String jsonTargetAddress =
-                    jsonCriterion.get("targetAddress").textValue();
-                if (!targetAddress.equals(jsonTargetAddress)) {
-                    description.appendText("target address was " +
-                                           jsonTargetAddress);
-                    return false;
-                }
-                break;
+                return matchCriterion(
+                        (Criteria.IPv6NDTargetAddressCriterion) criterion);
 
             case IPV6_ND_SLL:
             case IPV6_ND_TLL:
-                final Criteria.IPv6NDLinkLayerAddressCriterion
-                    ipv6NDLinkLayerAddressCriterion =
-                        (Criteria.IPv6NDLinkLayerAddressCriterion) criterion;
-                final String llAddress =
-                    ipv6NDLinkLayerAddressCriterion.mac().toString();
-                final String jsonLlAddress =
-                    jsonCriterion.get("mac").textValue();
-                if (!llAddress.equals(jsonLlAddress)) {
-                    description.appendText("mac was " + jsonLlAddress);
-                    return false;
-                }
-                break;
+                return matchCriterion(
+                        (Criteria.IPv6NDLinkLayerAddressCriterion) criterion);
 
             case MPLS_LABEL:
-                final Criteria.MplsCriterion mplsCriterion =
-                        (Criteria.MplsCriterion) criterion;
-                final int label = mplsCriterion.label();
-                final int jsonLabel = jsonCriterion.get("label").intValue();
-                if (label != jsonLabel) {
-                    description.appendText("label was " + Integer.toString(jsonLabel));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.MplsCriterion) criterion);
 
             case IPV6_EXTHDR:
-                final Criteria.IPv6ExthdrFlagsCriterion exthdrCriterion =
-                        (Criteria.IPv6ExthdrFlagsCriterion) criterion;
-                final int exthdrFlags = exthdrCriterion.exthdrFlags();
-                final int jsonExthdrFlags =
-                    jsonCriterion.get("exthdrFlags").intValue();
-                if (exthdrFlags != jsonExthdrFlags) {
-                    description.appendText("exthdrFlags was " + Long.toHexString(jsonExthdrFlags));
-                    return false;
-                }
-                break;
+                return matchCriterion(
+                        (Criteria.IPv6ExthdrFlagsCriterion) criterion);
 
             case OCH_SIGID:
-                final Criteria.LambdaCriterion lambdaCriterion =
-                        (Criteria.LambdaCriterion) criterion;
-                final int lambda = lambdaCriterion.lambda();
-                final int jsonLambda = jsonCriterion.get("lambda").intValue();
-                if (lambda != jsonLambda) {
-                    description.appendText("lambda was " + Integer.toString(lambda));
-                    return false;
-                }
-                break;
+                return matchCriterion((Criteria.LambdaCriterion) criterion);
 
             case OCH_SIGTYPE:
-                final Criteria.OpticalSignalTypeCriterion opticalSignalTypeCriterion =
-                        (Criteria.OpticalSignalTypeCriterion) criterion;
-                final short signalType = opticalSignalTypeCriterion.signalType();
-                final short jsonSignalType = jsonCriterion.get("signalType").shortValue();
-                if (signalType != jsonSignalType) {
-                    description.appendText("signal type was " + Short.toString(signalType));
-                    return false;
-                }
-                break;
+                return matchCriterion(
+                        (Criteria.OpticalSignalTypeCriterion) criterion);
 
             default:
                 // Don't know how to format this type
@@ -334,21 +561,10 @@
                         criterion.type());
                 return false;
         }
-        return true;
     }
 
     @Override
     public void describeTo(Description description) {
         description.appendText(criterion.toString());
     }
-
-    /**
-     * Factory to allocate an criterion matcher.
-     *
-     * @param criterion criterion object we are looking for
-     * @return matcher
-     */
-    public static CriterionJsonMatcher matchesCriterion(Criterion criterion) {
-        return new CriterionJsonMatcher(criterion);
-    }
 }
