Bug 752 - removed model ambiguities
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10FlowModInputMessageFactory.java
index 7821cd4979ad354993b1c37f63fd822c8a1da9a4..7fe217a6a5e725bd3f55074eed4358a1671808d5 100644 (file)
@@ -1,75 +1,82 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
-\r
-/**\r
- * Translates FlowMod messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10FlowModInputMessageFactory implements OFSerializer<FlowModInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 14;\r
-    private static final int MESSAGE_LENGTH = 72;\r
-    \r
-    private static OF10FlowModInputMessageFactory instance;\r
-   \r
-    private OF10FlowModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10FlowModInputMessageFactory getInstance() {\r
-        if(instance == null) {\r
-            instance = new OF10FlowModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        OF10MatchSerializer.encodeMatchV10(out, message.getMatchV10());\r
-        out.writeLong(message.getCookie().longValue());\r
-        out.writeShort(message.getCommand().getIntValue());\r
-        out.writeShort(message.getIdleTimeout().intValue());\r
-        out.writeShort(message.getHardTimeout().intValue());\r
-        out.writeShort(message.getPriority());\r
-        out.writeInt(message.getBufferId().intValue());\r
-        out.writeShort(message.getOutPort().getValue().intValue());\r
-        out.writeShort(createFlowModFlagsBitmask(message.getFlagsV10()));\r
-        OF10ActionsSerializer.encodeActionsV10(out, message.getActionsList());\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(FlowModInput message) {\r
-        return MESSAGE_LENGTH + OF10ActionsSerializer.computeActionsLength(message.getActionsList());\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-    private static int createFlowModFlagsBitmask(FlowModFlagsV10 flags) {\r
-        int flowModFlagBitmask = 0;\r
-        Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();\r
-        flowModFlagsMap.put(0, flags.isOFPFFSENDFLOWREM());\r
-        flowModFlagsMap.put(1, flags.isOFPFFCHECKOVERLAP());\r
-        flowModFlagsMap.put(2, flags.isOFPFFEMERG());\r
-        flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);\r
-        return flowModFlagBitmask;\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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+
+/**
+ * Translates FlowMod messages
+ * @author michal.polkorab
+ */
+public class OF10FlowModInputMessageFactory implements OFSerializer<FlowModInput> {
+
+    private static final byte MESSAGE_TYPE = 14;
+    private static final int MESSAGE_LENGTH = 72;
+    
+    private static OF10FlowModInputMessageFactory instance;
+   
+    private OF10FlowModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10FlowModInputMessageFactory getInstance() {
+        if(instance == null) {
+            instance = new OF10FlowModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        OF10MatchSerializer.encodeMatchV10(out, message.getMatchV10());
+        out.writeLong(message.getCookie().longValue());
+        out.writeShort(message.getCommand().getIntValue());
+        out.writeShort(message.getIdleTimeout().intValue());
+        out.writeShort(message.getHardTimeout().intValue());
+        out.writeShort(message.getPriority());
+        out.writeInt(message.getBufferId().intValue());
+        out.writeShort(message.getOutPort().getValue().intValue());
+        out.writeShort(createFlowModFlagsBitmask(message.getFlagsV10()));
+        OF10ActionsSerializer.encodeActionsV10(out, message.getAction());
+    }
+
+    @Override
+    public int computeLength(FlowModInput message) {
+        return MESSAGE_LENGTH + OF10ActionsSerializer.computeActionsLength(message.getAction());
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+    private static int createFlowModFlagsBitmask(FlowModFlagsV10 flags) {
+        int flowModFlagBitmask = 0;
+        Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();
+        flowModFlagsMap.put(0, flags.isOFPFFSENDFLOWREM());
+        flowModFlagsMap.put(1, flags.isOFPFFCHECKOVERLAP());
+        flowModFlagsMap.put(2, flags.isOFPFFEMERG());
+        flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);
+        return flowModFlagBitmask;
+    }
+}