2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
11 import java.util.concurrent.atomic.AtomicLong;
13 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
14 import org.openflow.protocol.OFMessage;
17 * This class describes an OpenFlow message with priority
19 class PriorityMessage {
22 final static AtomicLong seq = new AtomicLong();
24 boolean syncReply; // set to true if we want to be blocked until the response arrives
26 public PriorityMessage(OFMessage msg, int priority) {
28 this.priority = priority;
29 this.seqNum = seq.getAndIncrement();
30 this.syncReply = false;
33 public PriorityMessage(OFMessage msg, int priority, boolean syncReply) {
35 this.syncReply = syncReply;
38 public OFMessage getMsg() {
42 public void setMsg(OFMessage msg) {
46 public int getPriority() {
50 public void setPriority(int priority) {
51 this.priority = priority;
55 public int hashCode() {
58 result = prime * result + ((msg == null) ? 0 : msg.hashCode());
59 result = prime * result + priority;
60 result = prime * result + (int) (seqNum ^ (seqNum >>> 32));
61 result = prime * result + (syncReply ? 1231 : 1237);
66 public boolean equals(Object obj) {
71 if (getClass() != obj.getClass())
73 PriorityMessage other = (PriorityMessage) obj;
75 if (other.msg != null)
77 } else if (!msg.equals(other.msg))
79 if (priority != other.priority)
81 if (seqNum != other.seqNum)
83 if (syncReply != other.syncReply)
89 public String toString() {
90 return "PriorityMessage [msg=" + msg + ", priority=" + priority
91 + ", seqNum=" + seqNum + ", syncReply=" + syncReply + "]";