pcep: End of code cleaning 93/85593/9
authorOlivier Dugeon <olivier.dugeon@orange.com>
Tue, 5 Nov 2019 14:19:16 +0000 (15:19 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Nov 2019 15:51:59 +0000 (16:51 +0100)
 - Remove remaining call to deprecated functions
 - Change last ListArray by ArrayList

JIRA: BGPCEP-715
Change-Id: I17a57aea67f5ad174967c724bf6ab923987bc85a
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PathBindingTlvParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/AbstractSrSubobjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPExtensionProviderContext.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/pojo/SimplePCEPExtensionProviderContext.java
pcep/spi/src/test/java/org/opendaylight/protocol/pcep/spi/RegistryTest.java
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/session/stats/SessionStateImpl.java

index bd13a14d04296db5dfab27c4866880c00130a807..537cddf0b1ee6010fd7a6584c1aae7a95ae82279 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
+import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.Uint8;
 
@@ -84,7 +85,7 @@ public final class PathBindingTlvParser implements TlvParser, TlvSerializer {
         final PathBindingTlvCodec codec = BT_SERIALIZERS.get(bindingTypeValue.implementedInterface());
         Preconditions.checkArgument(codec != null,
             "Unsupported Path Binding Type: %s", bindingTypeValue.implementedInterface());
-        ByteBufWriteUtil.writeUnsignedShort(codec.getBindingType(), body);
+        ByteBufWriteUtil.writeUnsignedShort(Uint16.valueOf(codec.getBindingType()), body);
         body.writeBytes(codec.serialize(bindingTypeValue));
 
         TlvUtil.formatTlv(TYPE, body, buffer);
@@ -110,7 +111,7 @@ public final class PathBindingTlvParser implements TlvParser, TlvSerializer {
             Preconditions.checkArgument(bindingValue instanceof MplsLabel, "bindingValue is not MplsLabel");
             final MplsLabel mplsLabel = (MplsLabel) bindingValue;
             final ByteBuf value = Unpooled.buffer(MPLS_ENTRY_LENGTH);
-            ByteBufWriteUtil.writeUnsignedInt(getMplsStackEntry(mplsLabel.getMplsLabel()), value);
+            ByteBufWriteUtil.writeUnsignedInt(Uint32.valueOf(getMplsStackEntry(mplsLabel.getMplsLabel())), value);
             return value;
         }
 
@@ -139,18 +140,18 @@ public final class PathBindingTlvParser implements TlvParser, TlvSerializer {
                     | mplsEntry.getTrafficClass().toJava() << TC_SHIFT
                     | (mplsEntry.isBottomOfStack() ? 1 : 0) << S_SHIFT
                     | mplsEntry.getTimeToLive().toJava();
-            ByteBufWriteUtil.writeUnsignedInt(entry, value);
+            ByteBufWriteUtil.writeUnsignedInt(Uint32.valueOf(entry), value);
             return value;
         }
 
         @Override
         public BindingTypeValue deserialize(final ByteBuf buffer) {
-            final MplsLabelEntryBuilder builder = new MplsLabelEntryBuilder();
             final long entry = buffer.readUnsignedInt();
-            builder.setLabel(getMplsLabel(entry));
-            builder.setTrafficClass(Uint8.valueOf(entry >> TC_SHIFT & TC_MASK));
-            builder.setBottomOfStack((entry >> S_SHIFT & S_MASK) == 1);
-            builder.setTimeToLive(Uint8.valueOf(entry & TTL_MASK));
+            final MplsLabelEntryBuilder builder = new MplsLabelEntryBuilder()
+                    .setLabel(getMplsLabel(entry))
+                    .setTrafficClass(Uint8.valueOf(entry >> TC_SHIFT & TC_MASK))
+                    .setBottomOfStack((entry >> S_SHIFT & S_MASK) == 1)
+                    .setTimeToLive(Uint8.valueOf(entry & TTL_MASK));
             return builder.build();
         }
 
index cc60ea9d4a5a78791e47c5721ebff9acc885975b..76eba29c0943b6921b8247a923e6ac46666fd798 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.seg
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.UnnumberedAdjacency;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.UnnumberedAdjacencyBuilder;
 import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public abstract class AbstractSrSubobjectParser {
 
@@ -95,7 +96,7 @@ public abstract class AbstractSrSubobjectParser {
     public ByteBuf serializeSubobject(final SrSubobject srSubobject) {
         final ByteBuf buffer = Unpooled.buffer(MINIMAL_LENGTH);
         // sid type
-        writeUnsignedByte((short)(srSubobject.getSidType().getIntValue() << SID_TYPE_BITS_OFFSET), buffer);
+        writeUnsignedByte(Uint8.valueOf(srSubobject.getSidType().getIntValue() << SID_TYPE_BITS_OFFSET), buffer);
 
         final BitArray bits = new BitArray(BITSET_LENGTH);
         bits.set(M_FLAG_POSITION, srSubobject.isMFlag());
@@ -113,7 +114,7 @@ public abstract class AbstractSrSubobjectParser {
                 "Both SID and NAI are absent in SR subobject.");
         if (srSubobject.getSid() != null) {
             if (srSubobject.isMFlag()) {
-                writeUnsignedInt(srSubobject.getSid().toJava() << MPLS_LABEL_OFFSET, buffer);
+                writeUnsignedInt(Uint32.valueOf(srSubobject.getSid().intValue() << MPLS_LABEL_OFFSET), buffer);
             } else {
                 writeUnsignedInt(srSubobject.getSid(), buffer);
             }
index 8d3dd433ed77020f7e8c48452a7f9385966a0c9c..51f5248cbfd4a87c66c7d8978be5cdecc1b04e42 100644 (file)
@@ -32,9 +32,6 @@ public interface PCEPExtensionProviderContext extends PCEPExtensionConsumerConte
 
     Registration registerObjectParser(ObjectParser parser);
 
-    @Deprecated
-    Registration registerObjectParser(int objectClass, int objectType, ObjectParser parser);
-
     Registration registerObjectSerializer(Class<? extends Object> objClass, ObjectSerializer serializer);
 
     Registration registerRROSubobjectParser(int subobjectType, RROSubobjectParser parser);
index 45b9f19f6104e2a50e8f1aa2932fcd85c7c8b759..ed31068e65351405c2f2c962fc035350cb830a17 100644 (file)
@@ -125,12 +125,6 @@ public class SimplePCEPExtensionProviderContext implements PCEPExtensionProvider
         return this.msgReg.registerMessageSerializer(msgClass, serializer);
     }
 
-    @Override
-    public final Registration registerObjectParser(final int objectClass, final int objectType,
-            final ObjectParser parser) {
-        return this.objReg.registerObjectParser(objectClass, objectType, parser);
-    }
-
     @Override
     public final Registration registerObjectParser(final ObjectParser parser) {
         return this.objReg.registerObjectParser(parser.getObjectClass(), parser.getObjectType(), parser);
index 23f7839d8e7fe7855107e70c45d9a665d04025d6..1bfa1a9b5233f29f66965b91eb931bf8a9ed9465 100644 (file)
@@ -111,6 +111,7 @@ public class RegistryTest {
 
     final PCEPExtensionProviderContext ctx = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
 
+    @SuppressWarnings("unchecked")
     @Before
     public void setUp() throws PCEPDeserializerException {
         doReturn(null).when(this.xroParser).parseSubobject(any(ByteBuf.class), anyBoolean());
index d98092ab807b96033610d6ee8ea87fc4b8d3bf4f..cd14fbdce8e12ff0e7df620b492be27e040cdedd 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.protocol.pcep.testtool;
 
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
@@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SimpleSessionListener implements PCEPSessionListener {
 
-    private final List<Message> messages = Lists.newArrayList();
+    private final List<Message> messages = new ArrayList<>();
 
     private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
 
index db372ae447f024b9c8129144b4f116560252aa2b..021249c63bf507aabd3e565a2f2c41e477768e22 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.sta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
 import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public final class SessionStateImpl implements PcepSessionState {
     private final LongAdder lastReceivedRptMsgTimestamp = new LongAdder();
@@ -145,10 +146,10 @@ public final class SessionStateImpl implements PcepSessionState {
 
     private StatefulMessagesStatsAug createStatefulMessages() {
         return new StatefulMessagesStatsAugBuilder()
-                .setLastReceivedRptMsgTimestamp(this.lastReceivedRptMsgTimestamp.longValue())
-                .setReceivedRptMsgCount(this.receivedRptMsgCount.longValue())
-                .setSentInitMsgCount(this.sentInitMsgCount.longValue())
-                .setSentUpdMsgCount(this.sentUpdMsgCount.longValue())
+                .setLastReceivedRptMsgTimestamp(Uint32.valueOf(this.lastReceivedRptMsgTimestamp.longValue()))
+                .setReceivedRptMsgCount(Uint32.valueOf(this.receivedRptMsgCount.longValue()))
+                .setSentInitMsgCount(Uint32.valueOf(this.sentInitMsgCount.longValue()))
+                .setSentUpdMsgCount(Uint32.valueOf(this.sentUpdMsgCount.longValue()))
                 .build();
     }
 
@@ -158,9 +159,9 @@ public final class SessionStateImpl implements PcepSessionState {
             avg = Math.round((double) this.totalTime.longValue() / this.reqCount.longValue());
         }
         return new ReplyTimeBuilder()
-                .setAverageTime(avg)
-                .setMaxTime(this.maxReplyTime.longValue())
-                .setMinTime(this.minReplyTime.longValue())
+                .setAverageTime(Uint32.valueOf(avg))
+                .setMaxTime(Uint32.valueOf(this.maxReplyTime.longValue()))
+                .setMinTime(Uint32.valueOf(this.minReplyTime.longValue()))
                 .build();
     }