Migrate boolean getters
[bgpcep.git] / bgp / parser-impl / src / main / java / org / opendaylight / protocol / bgp / parser / impl / message / update / UnrecognizedAttributesSerializer.java
old mode 100755 (executable)
new mode 100644 (file)
index e753ad7..dce4030
@@ -5,18 +5,16 @@
  * 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.protocol.bgp.parser.impl.message.update;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import java.util.List;
+import java.util.Map;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.UnrecognizedAttributes;
-import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributesKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -24,22 +22,23 @@ public class UnrecognizedAttributesSerializer implements AttributeSerializer {
     private static final Logger LOG = LoggerFactory.getLogger(UnrecognizedAttributesSerializer.class);
 
     @Override
-    public void serializeAttribute(final DataObject attributes, final ByteBuf byteAggregator) {
-        Preconditions.checkArgument(attributes instanceof Attributes, "Attributes parameter is not a PathAttribute object.");
-        final List<UnrecognizedAttributes> unrecognizedAttrs = ((Attributes) attributes).getUnrecognizedAttributes();
+    public void serializeAttribute(final Attributes attributes, final ByteBuf byteAggregator) {
+        final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> unrecognizedAttrs =
+                attributes.getUnrecognizedAttributes();
         if (unrecognizedAttrs == null) {
             return;
         }
-        for (final UnrecognizedAttributes unrecognizedAttr: unrecognizedAttrs) {
+        for (final UnrecognizedAttributes unrecognizedAttr : unrecognizedAttrs.values()) {
             LOG.trace("Serializing unrecognized attribute of type {}", unrecognizedAttr.getType());
             int flags = AttributeUtil.OPTIONAL;
-            if (unrecognizedAttr.isPartial()) {
+            if (unrecognizedAttr.getPartial()) {
                 flags |= AttributeUtil.PARTIAL;
             }
-            if (unrecognizedAttr.isTransitive()) {
+            if (unrecognizedAttr.getTransitive()) {
                 flags |= AttributeUtil.TRANSITIVE;
             }
-            AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType(), Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
+            AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType().toJava(),
+                    Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
         }
     }