Avoid object creation and NullPointerException on unboxing

Change-Id: I9b372e7fcf6fb286834fabad60714fe58188b269
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
index 9ce3186..d67e63a 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
@@ -141,7 +141,7 @@
         }
 
         @Override
-        public Builder matchMetadata(Long metadata) {
+        public Builder matchMetadata(long metadata) {
             return add(Criteria.matchMetadata(metadata));
         }
 
@@ -156,7 +156,7 @@
         }
 
         @Override
-        public Builder matchEthType(Short ethType) {
+        public Builder matchEthType(short ethType) {
             return add(Criteria.matchEthType(ethType));
         }
 
@@ -166,22 +166,22 @@
         }
 
         @Override
-        public Builder matchVlanPcp(Byte vlanPcp) {
+        public Builder matchVlanPcp(byte vlanPcp) {
             return add(Criteria.matchVlanPcp(vlanPcp));
         }
 
         @Override
-        public Builder matchIPDscp(Byte ipDscp) {
+        public Builder matchIPDscp(byte ipDscp) {
             return add(Criteria.matchIPDscp(ipDscp));
         }
 
         @Override
-        public Builder matchIPEcn(Byte ipEcn) {
+        public Builder matchIPEcn(byte ipEcn) {
             return add(Criteria.matchIPEcn(ipEcn));
         }
 
         @Override
-        public Builder matchIPProtocol(Byte proto) {
+        public Builder matchIPProtocol(byte proto) {
             return add(Criteria.matchIPProtocol(proto));
         }
 
@@ -196,42 +196,42 @@
         }
 
         @Override
-        public Builder matchTcpSrc(Short tcpPort) {
+        public Builder matchTcpSrc(short tcpPort) {
             return add(Criteria.matchTcpSrc(tcpPort));
         }
 
         @Override
-        public Builder matchTcpDst(Short tcpPort) {
+        public Builder matchTcpDst(short tcpPort) {
             return add(Criteria.matchTcpDst(tcpPort));
         }
 
         @Override
-        public Builder matchUdpSrc(Short udpPort) {
+        public Builder matchUdpSrc(short udpPort) {
             return add(Criteria.matchUdpSrc(udpPort));
         }
 
         @Override
-        public Builder matchUdpDst(Short udpPort) {
+        public Builder matchUdpDst(short udpPort) {
             return add(Criteria.matchUdpDst(udpPort));
         }
 
         @Override
-        public Builder matchSctpSrc(Short sctpPort) {
+        public Builder matchSctpSrc(short sctpPort) {
             return add(Criteria.matchSctpSrc(sctpPort));
         }
 
         @Override
-        public Builder matchSctpDst(Short sctpPort) {
+        public Builder matchSctpDst(short sctpPort) {
             return add(Criteria.matchSctpDst(sctpPort));
         }
 
         @Override
-        public Builder matchIcmpType(Byte icmpType) {
+        public Builder matchIcmpType(byte icmpType) {
             return add(Criteria.matchIcmpType(icmpType));
         }
 
         @Override
-        public Builder matchIcmpCode(Byte icmpCode) {
+        public Builder matchIcmpCode(byte icmpCode) {
             return add(Criteria.matchIcmpCode(icmpCode));
         }
 
@@ -246,17 +246,17 @@
         }
 
         @Override
-        public Builder matchIPv6FlowLabel(Integer flowLabel) {
+        public Builder matchIPv6FlowLabel(int flowLabel) {
             return add(Criteria.matchIPv6FlowLabel(flowLabel));
         }
 
         @Override
-        public Builder matchIcmpv6Type(Byte icmpv6Type) {
+        public Builder matchIcmpv6Type(byte icmpv6Type) {
             return add(Criteria.matchIcmpv6Type(icmpv6Type));
         }
 
         @Override
-        public Builder matchIcmpv6Code(Byte icmpv6Code) {
+        public Builder matchIcmpv6Code(byte icmpv6Code) {
             return add(Criteria.matchIcmpv6Code(icmpv6Code));
         }
 
@@ -281,17 +281,17 @@
         }
 
         @Override
-        public Builder matchIPv6ExthdrFlags(Integer exthdrFlags) {
+        public Builder matchIPv6ExthdrFlags(int exthdrFlags) {
             return add(Criteria.matchIPv6ExthdrFlags(exthdrFlags));
         }
 
         @Override
-        public Builder matchLambda(Short lambda) {
+        public Builder matchLambda(short lambda) {
             return add(Criteria.matchLambda(lambda));
         }
 
         @Override
-        public Builder matchOpticalSignalType(Short signalType) {
+        public Builder matchOpticalSignalType(short signalType) {
             return add(Criteria.matchOpticalSignalType(signalType));
         }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
index 533e2f5..ffdafd7 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
@@ -82,7 +82,7 @@
          * @param metadata the metadata
          * @return a selection builder
          */
-        public Builder matchMetadata(Long metadata);
+        public Builder matchMetadata(long metadata);
 
         /**
          * Matches a l2 dst address.
@@ -106,7 +106,7 @@
          * @param ethType an ethernet type
          * @return a selection builder
          */
-        public Builder matchEthType(Short ethType);
+        public Builder matchEthType(short ethType);
 
         /**
          * Matches the vlan id.
@@ -122,7 +122,7 @@
          * @param vlanPcp a vlan priority
          * @return a selection builder
          */
-        public Builder matchVlanPcp(Byte vlanPcp);
+        public Builder matchVlanPcp(byte vlanPcp);
 
         /**
          * Matches an IP DSCP (6 bits in ToS field).
@@ -130,7 +130,7 @@
          * @param ipDscp an IP DSCP value
          * @return a selection builder
          */
-        public Builder matchIPDscp(Byte ipDscp);
+        public Builder matchIPDscp(byte ipDscp);
 
         /**
          * Matches an IP ECN (2 bits in ToS field).
@@ -138,7 +138,7 @@
          * @param ipEcn an IP ECN value
          * @return a selection builder
          */
-        public Builder matchIPEcn(Byte ipEcn);
+        public Builder matchIPEcn(byte ipEcn);
 
         /**
          * Matches the l3 protocol.
@@ -146,7 +146,7 @@
          * @param proto a l3 protocol
          * @return a selection builder
          */
-        public Builder matchIPProtocol(Byte proto);
+        public Builder matchIPProtocol(byte proto);
 
         /**
          * Matches a l3 IPv4 address.
@@ -170,7 +170,7 @@
          * @param tcpPort a TCP source port number
          * @return a selection builder
          */
-        public Builder matchTcpSrc(Short tcpPort);
+        public Builder matchTcpSrc(short tcpPort);
 
         /**
          * Matches a TCP destination port number.
@@ -178,7 +178,7 @@
          * @param tcpPort a TCP destination port number
          * @return a selection builder
          */
-        public Builder matchTcpDst(Short tcpPort);
+        public Builder matchTcpDst(short tcpPort);
 
         /**
          * Matches an UDP source port number.
@@ -186,7 +186,7 @@
          * @param udpPort an UDP source port number
          * @return a selection builder
          */
-        public Builder matchUdpSrc(Short udpPort);
+        public Builder matchUdpSrc(short udpPort);
 
         /**
          * Matches an UDP destination port number.
@@ -194,7 +194,7 @@
          * @param udpPort an UDP destination port number
          * @return a selection builder
          */
-        public Builder matchUdpDst(Short udpPort);
+        public Builder matchUdpDst(short udpPort);
 
         /**
          * Matches a SCTP source port number.
@@ -202,7 +202,7 @@
          * @param sctpPort a SCTP source port number
          * @return a selection builder
          */
-        public Builder matchSctpSrc(Short sctpPort);
+        public Builder matchSctpSrc(short sctpPort);
 
         /**
          * Matches a SCTP destination port number.
@@ -210,7 +210,7 @@
          * @param sctpPort a SCTP destination port number
          * @return a selection builder
          */
-        public Builder matchSctpDst(Short sctpPort);
+        public Builder matchSctpDst(short sctpPort);
 
         /**
          * Matches an ICMP type.
@@ -218,7 +218,7 @@
          * @param icmpType an ICMP type
          * @return a selection builder
          */
-        public Builder matchIcmpType(Byte icmpType);
+        public Builder matchIcmpType(byte icmpType);
 
         /**
          * Matches an ICMP code.
@@ -226,7 +226,7 @@
          * @param icmpCode an ICMP code
          * @return a selection builder
          */
-        public Builder matchIcmpCode(Byte icmpCode);
+        public Builder matchIcmpCode(byte icmpCode);
 
         /**
          * Matches a l3 IPv6 address.
@@ -250,7 +250,7 @@
          * @param flowLabel an IPv6 flow label
          * @return a selection builder
          */
-        public Builder matchIPv6FlowLabel(Integer flowLabel);
+        public Builder matchIPv6FlowLabel(int flowLabel);
 
         /**
          * Matches an ICMPv6 type.
@@ -258,7 +258,7 @@
          * @param icmpv6Type an ICMPv6 type
          * @return a selection builder
          */
-        public Builder matchIcmpv6Type(Byte icmpv6Type);
+        public Builder matchIcmpv6Type(byte icmpv6Type);
 
         /**
          * Matches an ICMPv6 code.
@@ -266,7 +266,7 @@
          * @param icmpv6Code an ICMPv6 code
          * @return a selection builder
          */
-        public Builder matchIcmpv6Code(Byte icmpv6Code);
+        public Builder matchIcmpv6Code(byte icmpv6Code);
 
         /**
          * Matches an IPv6 Neighbor Discovery target address.
@@ -306,7 +306,7 @@
          * @param exthdrFlags the IPv6 Extension Header pseudo-field fiags
          * @return a selection builder
          */
-        public Builder matchIPv6ExthdrFlags(Integer exthdrFlags);
+        public Builder matchIPv6ExthdrFlags(int exthdrFlags);
 
         /**
          * Matches an optical signal ID or lambda.
@@ -314,7 +314,7 @@
          * @param lambda lamda
          * @return a selection builder
          */
-        public Builder matchLambda(Short lambda);
+        public Builder matchLambda(short lambda);
 
         /**
          * Matches an optical Signal Type.
@@ -322,7 +322,7 @@
          * @param signalType signalType
          * @return a selection builder
          */
-        public Builder matchOpticalSignalType(Short signalType);
+        public Builder matchOpticalSignalType(short signalType);
 
         /**
          * Builds an immutable traffic selector.