Merge "Increase timeout for waiting for broker service in sal-binding-it."
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / PriorityMessage.java
index 2f23d36e073ca9aa6ccc95e335b3bd6295ca419f..7893ae0acca4f37e22a6fecee532b902652d2f0f 100644 (file)
@@ -10,9 +10,6 @@ package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
 
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.OFMessage;
 
 /**
@@ -23,11 +20,18 @@ class PriorityMessage {
     int priority;
     final static AtomicLong seq = new AtomicLong();
     final long seqNum;
+    boolean syncReply; // set to true if we want to be blocked until the response arrives
 
     public PriorityMessage(OFMessage msg, int priority) {
         this.msg = msg;
         this.priority = priority;
         this.seqNum = seq.getAndIncrement();
+        this.syncReply = false;
+    }
+
+    public PriorityMessage(OFMessage msg, int priority, boolean syncReply) {
+        this(msg, priority);
+        this.syncReply = syncReply;
     }
 
     public OFMessage getMsg() {
@@ -48,17 +52,41 @@ class PriorityMessage {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((msg == null) ? 0 : msg.hashCode());
+        result = prime * result + priority;
+        result = prime * result + (int) (seqNum ^ (seqNum >>> 32));
+        result = prime * result + (syncReply ? 1231 : 1237);
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        PriorityMessage other = (PriorityMessage) obj;
+        if (msg == null) {
+            if (other.msg != null)
+                return false;
+        } else if (!msg.equals(other.msg))
+            return false;
+        if (priority != other.priority)
+            return false;
+        if (seqNum != other.seqNum)
+            return false;
+        if (syncReply != other.syncReply)
+            return false;
+        return true;
     }
 
     @Override
     public String toString() {
-        return "PriorityMessage[" + ReflectionToStringBuilder.toString(this)
-                + "]";
+        return "PriorityMessage [msg=" + msg + ", priority=" + priority
+                + ", seqNum=" + seqNum + ", syncReply=" + syncReply + "]";
     }
 }