Bug 1277 - Move ByteBuffUtils to separate bundle
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / BarrierReplyMessageFactory.java
index 3ec397520ebf38dc5db752ee6e092badd236816d..4c109ca6624e908840e1ac9ab1f417bd16ad2094 100644 (file)
@@ -1,41 +1,32 @@
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- * \r
- */\r
-public class BarrierReplyMessageFactory implements\r
-        OFDeserializer<BarrierOutput> {\r
-\r
-    private static BarrierReplyMessageFactory instance;\r
-\r
-    private BarrierReplyMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-\r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static BarrierReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new BarrierReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public BarrierOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        BarrierOutputBuilder bob = new BarrierOutputBuilder();\r
-        bob.setVersion(version);\r
-        bob.setXid(rawMessage.readUnsignedInt());\r
-        return bob.build();\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
+
+/**
+ * Translates BarrierReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {
+
+    @Override
+    public BarrierOutput deserialize(ByteBuf rawMessage) {
+        BarrierOutputBuilder builder = new BarrierOutputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+}