Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowjava / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / TypeToClassKey.java
index 5e67ff75d57b44432f3a726b251b8bcd06616cae..c2dc9980e6c5caf93ef82fde6cd56a2baebcac44 100644 (file)
@@ -7,14 +7,17 @@
  */
 package org.opendaylight.openflowjava.protocol.api.keys;
 
+import static java.util.Objects.requireNonNull;
+
+import org.opendaylight.yangtools.yang.common.Uint8;
+
 /**
  * Key for a class type.
  *
  * @author michal.polkorab
  */
 public class TypeToClassKey {
-
-    private final short version;
+    private final Uint8 version;
     private final int type;
 
     /**
@@ -23,8 +26,8 @@ public class TypeToClassKey {
      * @param version wire protocol version
      * @param type message type / code
      */
-    public TypeToClassKey(short version, int type) {
-        this.version = version;
+    public TypeToClassKey(final Uint8 version, final int type) {
+        this.version = requireNonNull(version);
         this.type = type;
     }
 
@@ -37,7 +40,7 @@ public class TypeToClassKey {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
@@ -48,12 +51,6 @@ public class TypeToClassKey {
             return false;
         }
         TypeToClassKey other = (TypeToClassKey) obj;
-        if (type != other.type) {
-            return false;
-        }
-        if (version != other.version) {
-            return false;
-        }
-        return true;
+        return type == other.type && version.equals(other.version);
     }
 }