2f23d36e073ca9aa6ccc95e335b3bd6295ca419f
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / PriorityMessage.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
10
11 import java.util.concurrent.atomic.AtomicLong;
12
13 import org.apache.commons.lang3.builder.EqualsBuilder;
14 import org.apache.commons.lang3.builder.HashCodeBuilder;
15 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
16 import org.openflow.protocol.OFMessage;
17
18 /**
19  * This class describes an OpenFlow message with priority
20  */
21 class PriorityMessage {
22     OFMessage msg;
23     int priority;
24     final static AtomicLong seq = new AtomicLong();
25     final long seqNum;
26
27     public PriorityMessage(OFMessage msg, int priority) {
28         this.msg = msg;
29         this.priority = priority;
30         this.seqNum = seq.getAndIncrement();
31     }
32
33     public OFMessage getMsg() {
34         return msg;
35     }
36
37     public void setMsg(OFMessage msg) {
38         this.msg = msg;
39     }
40
41     public int getPriority() {
42         return priority;
43     }
44
45     public void setPriority(int priority) {
46         this.priority = priority;
47     }
48
49     @Override
50     public int hashCode() {
51         return HashCodeBuilder.reflectionHashCode(this);
52     }
53
54     @Override
55     public boolean equals(Object obj) {
56         return EqualsBuilder.reflectionEquals(this, obj);
57     }
58
59     @Override
60     public String toString() {
61         return "PriorityMessage[" + ReflectionToStringBuilder.toString(this)
62                 + "]";
63     }
64 }