Merge "Use String(byte[], Charset)"
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / VersionMessageWrapper.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. 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 package org.opendaylight.openflowjava.protocol.impl.core;
9
10 import static java.util.Objects.requireNonNull;
11
12 import io.netty.buffer.ByteBuf;
13
14 /**
15  * Wraps received messages (includes version).
16  *
17  * @author michal.polkorab
18  */
19 public class VersionMessageWrapper {
20     private final short version;
21     private final ByteBuf messageBuffer;
22
23     /**
24      * Constructor.
25      *
26      * @param version version decoded in {@link OFVersionDetector}
27      * @param messageBuffer message received from {@link OFFrameDecoder}
28      */
29     public VersionMessageWrapper(final short version, final ByteBuf messageBuffer) {
30         this.version = version;
31         this.messageBuffer = requireNonNull(messageBuffer);
32     }
33
34     /**
35      * Returns the version version decoded in {@link OFVersionDetector}.
36      *
37      * @return the version version decoded in {@link OFVersionDetector}
38      */
39     public short getVersion() {
40         return version;
41     }
42
43     /**
44      * Returns the messageBuffer message received from {@link OFFrameDecoder}.
45      *
46      * @return the messageBuffer message received from {@link OFFrameDecoder}
47      */
48     public ByteBuf getMessageBuffer() {
49         return messageBuffer;
50     }
51 }