BUG-2825: use provided Ipv4/MacAddress factories
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / match / AbstractOxmIpv4AddressSerializer.java
index ea9d0a5c3bad82fbfa27410d87782c0fee0f94f7..5dcba7ab9732fde80da70908dca38ee26bea111b 100644 (file)
@@ -8,8 +8,9 @@
 package org.opendaylight.openflowjava.protocol.impl.serialization.match;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 
 /**
  * Parent for Ipv4 address based match entry serializers
@@ -17,11 +18,18 @@ import org.opendaylight.openflowjava.util.ByteBufUtils;
  */
 public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer {
 
-    protected static void writeIpv4Address(String address, final ByteBuf out) {
+    /**
+     * @deprecated Use {@link #writeIpv4Address(Ipv4Address, ByteBuf)} instead.
+     */
+    @Deprecated
+    protected static void writeIpv4Address(final String address, final ByteBuf out) {
         Iterable<String> addressGroups = ByteBufUtils.DOT_SPLITTER.split(address);
         for (String group : addressGroups) {
             out.writeByte(Short.parseShort(group));
         }
     }
 
+    protected static void writeIpv4Address(final Ipv4Address address, final ByteBuf out) {
+        out.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(address));
+    }
 }