Code clean up 56/72356/1
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Fri, 25 May 2018 07:16:54 +0000 (09:16 +0200)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Mon, 28 May 2018 08:30:03 +0000 (10:30 +0200)
- check style
- Qname generation
- functional style
- java language migration
- mvn duplication

Change-Id: I0c7757c8cadead5e988cde6d3fa0e607c4cad72c
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
53 files changed:
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/ipv4/FlowspecIpv4NlriParserHelper.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/ipv6/FlowspecIpv6NlriParserHelper.java
bgp/inet/src/test/java/org/opendaylight/protocol/bgp/inet/codec/Ipv4NlriParserTest.java
bgp/labeled-unicast/src/test/java/org/opendaylight/protocol/bgp/labeled/unicast/BgpPrefixSidTlvsTest.java
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/LinkstateNlriParser.java
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/NodeNlriParser.java
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/OspfRouteTlvParser.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/ConditionsRegistryImpl.java
bgp/openconfig-state/src/main/java/org/opendaylight/protocol/bgp/state/NeighborUtil.java
bgp/openconfig-state/src/test/java/org/opendaylight/protocol/bgp/state/StateProviderImplTest.java
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/TableTypeTest.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/open/MultiProtocolCapabilityHandler.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/ComplementaryTest.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseBestPathTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeerTrackerImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImpl.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractRIBTestSetup.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/RouteUpdateKeyTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SimpleSessionListener.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/AbstractConfig.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupportTest.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/RouterIdsTest.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractTopologyBuilder.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/ProtocolUtil.java
bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateTopologyBuilderTest.java
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/BmpDispatcherImpl.java
bmp/bmp-mock/src/main/java/org/opendaylight/protocol/bmp/mock/BmpMockDispatcher.java
bmp/bmp-mock/src/main/java/org/opendaylight/protocol/bmp/mock/BmpMockSessionListener.java
bmp/bmp-spi/src/test/java/org/opendaylight/protocol/bmp/spi/parser/AbstractBmpMessageWithTlvParserTest.java
concepts/src/test/java/org/opendaylight/protocol/concepts/ASNumberTest.java
features/bgp/odl-bgpcep-bgp/pom.xml
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROIpv4PrefixSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/TestingSessionListener.java
pcep/spi/src/test/java/org/opendaylight/protocol/pcep/spi/APITest.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/AbstractTopologySessionListener.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/OperationResults.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful07TopologySessionListener.java
programming/impl/src/test/java/org/opendaylight/bgpcep/programming/impl/ProgrammingServiceImplTest.java
testtool-util/src/main/java/org/opendaylight/protocol/util/InetSocketAddressUtil.java
testtool-util/src/test/java/org/opendaylight/protocol/util/CheckUtilTest.java
util/src/test/java/org/opendaylight/protocol/util/ByteArrayTest.java

index 5293646ff7a225dcabfeb593253c9ca7c9d71ace..e3f84b7a50d3a12ceaa69e72526cb43e0e12a461 100644 (file)
@@ -106,8 +106,10 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
     static final NodeIdentifier FLOWSPEC_NID = new NodeIdentifier(Flowspec.QNAME);
     @VisibleForTesting
     static final NodeIdentifier FLOWSPEC_TYPE_NID = new NodeIdentifier(FlowspecType.QNAME);
-    public static final NodeIdentifier DEST_PREFIX_NID = new NodeIdentifier(QName.create(DestinationPrefixCase.QNAME, "destination-prefix").intern());
-    public static final NodeIdentifier SOURCE_PREFIX_NID = new NodeIdentifier(QName.create(SourcePrefixCase.QNAME, "source-prefix").intern());
+    public static final NodeIdentifier DEST_PREFIX_NID
+            = new NodeIdentifier(QName.create(DestinationPrefixCase.QNAME, "destination-prefix").intern());
+    public static final NodeIdentifier SOURCE_PREFIX_NID
+            = new NodeIdentifier(QName.create(SourcePrefixCase.QNAME, "source-prefix").intern());
     @VisibleForTesting
     static final NodeIdentifier PORTS_NID = new NodeIdentifier(Ports.QNAME);
     @VisibleForTesting
@@ -127,11 +129,13 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
     @VisibleForTesting
     static final NodeIdentifier FRAGMENT_NID = new NodeIdentifier(Fragments.QNAME);
     @VisibleForTesting
-    public static final NodeIdentifier OP_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getNamespace(), Flowspec.QNAME.getRevision(), "op"));
+    public static final NodeIdentifier OP_NID
+            = new NodeIdentifier(QName.create(Flowspec.QNAME.getModule(), "op"));
     @VisibleForTesting
-    public static final NodeIdentifier VALUE_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getNamespace(), Flowspec.QNAME.getRevision(), "value"));
+    public static final NodeIdentifier VALUE_NID
+            = new NodeIdentifier(QName.create(Flowspec.QNAME.getModule(), "value"));
 
-    protected SimpleFlowspecTypeRegistry flowspecTypeRegistry;
+    protected final SimpleFlowspecTypeRegistry flowspecTypeRegistry;
 
     /**
      * Add this constant to length value to achieve all ones in the leftmost nibble.
@@ -170,7 +174,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
      * @param pathId     associated path id with given NLRI
      * @return created destination type
      */
-    public abstract DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId);
+    public abstract DestinationType createWithdrawnDestinationType(@Nonnull Object[] nlriFields,
+            @Nullable PathId pathId);
 
     /**
      * Create advertized destination type
@@ -179,11 +184,12 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
      * @param pathId     associated path id with given NLRI
      * @return created destination type
      */
-    public abstract DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId);
+    public abstract DestinationType createAdvertizedRoutesDestinationType(@Nonnull Object[] nlriFields, @Nullable PathId pathId);
 
     @Override
     public final void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
-        Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+        Preconditions.checkArgument(attribute instanceof Attributes,
+                "Attribute parameter is not a PathAttribute object.");
         final Attributes pathAttributes = (Attributes) attribute;
         final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
         final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
@@ -223,13 +229,15 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
      * @param pathId
      * @param buffer     where flowspec NLRI will be serialized
      */
-    protected final void serializeNlri(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId, @Nonnull final ByteBuf buffer) {
+    protected final void serializeNlri(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId,
+            @Nonnull final ByteBuf buffer) {
         final ByteBuf nlriByteBuf = Unpooled.buffer();
         PathIdUtil.writePathId(pathId, buffer);
 
         serializeNlri(nlriFields, nlriByteBuf);
 
-        Preconditions.checkState(nlriByteBuf.readableBytes() <= MAX_NLRI_LENGTH, "Maximum length of Flowspec NLRI reached.");
+        Preconditions.checkState(nlriByteBuf.readableBytes() <= MAX_NLRI_LENGTH,
+                "Maximum length of Flowspec NLRI reached.");
         if (nlriByteBuf.readableBytes() <= MAX_NLRI_LENGTH_ONE_BYTE) {
             buffer.writeByte(nlriByteBuf.readableBytes());
         } else {
@@ -262,23 +270,35 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
 
     private void processFlowspecType(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
         if (fsType.getChild(PORTS_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new PortCaseBuilder().setPorts(createPorts((UnkeyedListNode) fsType.getChild(PORTS_NID).get())).build());
+            fsBuilder.setFlowspecType(new PortCaseBuilder()
+                    .setPorts(createPorts((UnkeyedListNode) fsType.getChild(PORTS_NID).get())).build());
         } else if (fsType.getChild(DEST_PORT_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new DestinationPortCaseBuilder().setDestinationPorts(createDestinationPorts((UnkeyedListNode) fsType.getChild(DEST_PORT_NID).get())).build());
+            fsBuilder.setFlowspecType(new DestinationPortCaseBuilder()
+                    .setDestinationPorts(createDestinationPorts((UnkeyedListNode) fsType.getChild(DEST_PORT_NID).get()))
+                    .build());
         } else if (fsType.getChild(SOURCE_PORT_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new SourcePortCaseBuilder().setSourcePorts(createSourcePorts((UnkeyedListNode) fsType.getChild(SOURCE_PORT_NID).get())).build());
+            fsBuilder.setFlowspecType(new SourcePortCaseBuilder()
+                    .setSourcePorts(createSourcePorts((UnkeyedListNode) fsType.getChild(SOURCE_PORT_NID).get()))
+                    .build());
         } else if (fsType.getChild(ICMP_TYPE_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new IcmpTypeCaseBuilder().setTypes(createTypes((UnkeyedListNode) fsType.getChild(ICMP_TYPE_NID).get())).build());
+            fsBuilder.setFlowspecType(new IcmpTypeCaseBuilder()
+                    .setTypes(createTypes((UnkeyedListNode) fsType.getChild(ICMP_TYPE_NID).get())).build());
         } else if (fsType.getChild(ICMP_CODE_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new IcmpCodeCaseBuilder().setCodes(createCodes((UnkeyedListNode) fsType.getChild(ICMP_CODE_NID).get())).build());
+            fsBuilder.setFlowspecType(new IcmpCodeCaseBuilder()
+                    .setCodes(createCodes((UnkeyedListNode) fsType.getChild(ICMP_CODE_NID).get())).build());
         } else if (fsType.getChild(TCP_FLAGS_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(createTcpFlags((UnkeyedListNode) fsType.getChild(TCP_FLAGS_NID).get())).build());
+            fsBuilder.setFlowspecType(new TcpFlagsCaseBuilder()
+                    .setTcpFlags(createTcpFlags((UnkeyedListNode) fsType.getChild(TCP_FLAGS_NID).get())).build());
         } else if (fsType.getChild(PACKET_LENGTHS_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(createPacketLengths((UnkeyedListNode) fsType.getChild(PACKET_LENGTHS_NID).get())).build());
+            fsBuilder.setFlowspecType(new PacketLengthCaseBuilder()
+                    .setPacketLengths(createPacketLengths((UnkeyedListNode) fsType.getChild(PACKET_LENGTHS_NID).get()))
+                    .build());
         } else if (fsType.getChild(DSCP_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new DscpCaseBuilder().setDscps(createDscpsLengths((UnkeyedListNode) fsType.getChild(DSCP_NID).get())).build());
+            fsBuilder.setFlowspecType(new DscpCaseBuilder()
+                    .setDscps(createDscpsLengths((UnkeyedListNode) fsType.getChild(DSCP_NID).get())).build());
         } else if (fsType.getChild(FRAGMENT_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new FragmentCaseBuilder().setFragments(createFragments((UnkeyedListNode) fsType.getChild(FRAGMENT_NID).get())).build());
+            fsBuilder.setFlowspecType(new FragmentCaseBuilder()
+                    .setFragments(createFragments((UnkeyedListNode) fsType.getChild(FRAGMENT_NID).get())).build());
         } else {
             extractSpecificFlowspec(fsType, fsBuilder);
         }
@@ -290,13 +310,10 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : portsData.getValue()) {
             final PortsBuilder portsBuilder = new PortsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                portsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> portsBuilder
+                    .setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                portsBuilder.setValue((Integer) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild -> portsBuilder.setValue((Integer) dataContainerChild.getValue()));
             ports.add(portsBuilder.build());
         }
 
@@ -309,13 +326,11 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : destinationPortsData.getValue()) {
             final DestinationPortsBuilder destPortsBuilder = new DestinationPortsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                destPortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> destPortsBuilder.setOp(NumericTwoByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                destPortsBuilder.setValue((Integer) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild
+                    -> destPortsBuilder.setValue((Integer) dataContainerChild.getValue()));
             destinationPorts.add(destPortsBuilder.build());
         }
 
@@ -328,13 +343,11 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : sourcePortsData.getValue()) {
             final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> sourcePortsBuilder.setOp(NumericTwoByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                sourcePortsBuilder.setValue((Integer) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild
+                    -> sourcePortsBuilder.setValue((Integer) dataContainerChild.getValue()));
             sourcePorts.add(sourcePortsBuilder.build());
         }
 
@@ -347,13 +360,10 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : typesData.getValue()) {
             final TypesBuilder typesBuilder = new TypesBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                typesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> typesBuilder.setOp(NumericOneByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                typesBuilder.setValue((Short) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild -> typesBuilder.setValue((Short) dataContainerChild.getValue()));
             types.add(typesBuilder.build());
         }
 
@@ -366,13 +376,10 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : codesData.getValue()) {
             final CodesBuilder codesBuilder = new CodesBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                codesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> codesBuilder.setOp(NumericOneByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                codesBuilder.setValue((Short) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild -> codesBuilder.setValue((Short) dataContainerChild.getValue()));
             codes.add(codesBuilder.build());
         }
 
@@ -385,13 +392,11 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : tcpFlagsData.getValue()) {
             final TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                tcpFlagsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> tcpFlagsBuilder
+                    .setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                tcpFlagsBuilder.setValue((Integer) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild
+                    -> tcpFlagsBuilder.setValue((Integer) dataContainerChild.getValue()));
             tcpFlags.add(tcpFlagsBuilder.build());
         }
 
@@ -404,13 +409,11 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : packetLengthsData.getValue()) {
             final PacketLengthsBuilder packetLengthsBuilder = new PacketLengthsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                packetLengthsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> packetLengthsBuilder.setOp(NumericTwoByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                packetLengthsBuilder.setValue((Integer) valueNode.get().getValue());
-            }
+            valueNode.ifPresent(dataContainerChild
+                    -> packetLengthsBuilder.setValue((Integer) dataContainerChild.getValue()));
             packetLengths.add(packetLengthsBuilder.build());
         }
 
@@ -423,13 +426,11 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : dscpLengthsData.getValue()) {
             final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> dscpsLengthsBuilder.setOp(NumericOneByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                dscpsLengthsBuilder.setValue(new Dscp((Short) valueNode.get().getValue()));
-            }
+            valueNode.ifPresent(dataContainerChild
+                    -> dscpsLengthsBuilder.setValue(new Dscp((Short) dataContainerChild.getValue())));
             dscpsLengths.add(dscpsLengthsBuilder.build());
         }
 
@@ -442,13 +443,11 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         for (final UnkeyedListEntryNode node : fragmentsData.getValue()) {
             final FragmentsBuilder fragmentsBuilder = new FragmentsBuilder();
             final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
-            if (opValue.isPresent()) {
-                fragmentsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
+            opValue.ifPresent(dataContainerChild -> fragmentsBuilder.setOp(BitmaskOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
             final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
-            if (valueNode.isPresent()) {
-                fragmentsBuilder.setValue(createFragment((Set<String>) valueNode.get().getValue()));
-            }
+            valueNode.ifPresent(dataContainerChild
+                    -> fragmentsBuilder.setValue(createFragment((Set<String>) dataContainerChild.getValue())));
             fragments.add(fragmentsBuilder.build());
         }
 
@@ -456,7 +455,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
     }
 
     private static Fragment createFragment(final Set<String> data) {
-        return new Fragment(data.contains(DO_NOT_VALUE), data.contains(FIRST_VALUE), data.contains(IS_A_VALUE), data.contains(LAST_VALUE));
+        return new Fragment(data.contains(DO_NOT_VALUE), data.contains(FIRST_VALUE), data.contains(IS_A_VALUE),
+                data.contains(LAST_VALUE));
     }
 
     protected final String stringNlri(final List<Flowspec> flows) {
@@ -475,7 +475,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
             buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((PortCase) value).getPorts()));
         } else if (value instanceof DestinationPortCase) {
             buffer.append("where destination port ");
-            buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((DestinationPortCase) value).getDestinationPorts()));
+            buffer.append(NumericTwoByteOperandParser
+                    .INSTANCE.toString(((DestinationPortCase) value).getDestinationPorts()));
         } else if (value instanceof SourcePortCase) {
             buffer.append("where source port ");
             buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((SourcePortCase) value).getSourcePorts()));
@@ -565,7 +566,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
         if (length >= MAX_NLRI_LENGTH_ONE_BYTE) {
             length = (length << Byte.SIZE | nlri.readUnsignedByte()) & MAX_NLRI_LENGTH;
         }
-        Preconditions.checkState(length > 0 && length <= nlri.readableBytes(), "Invalid flowspec NLRI length %s", length);
+        Preconditions.checkState(length > 0 && length <= nlri.readableBytes(),
+                "Invalid flowspec NLRI length %s", length);
         return length;
     }
 
@@ -583,7 +585,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
 
         while (nlri.isReadable()) {
             int nlriLength = readNlriLength(nlri);
-            Preconditions.checkState(nlriLength > 0 && nlriLength <= nlri.readableBytes(), "Invalid flowspec NLRI length %s", nlriLength);
+            Preconditions.checkState(nlriLength > 0 && nlriLength <= nlri.readableBytes(),
+                    "Invalid flowspec NLRI length %s", nlriLength);
             LOG.trace("Flowspec NLRI length is {}", nlriLength);
 
             while (nlriLength > 0) {
@@ -594,7 +597,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
                 final int flowspecTypeLength = readableLength - nlri.readableBytes();
                 nlriLength -= flowspecTypeLength;
             }
-            Preconditions.checkState(nlriLength == 0, "Remain NLRI length should be 0 instead of %s", nlriLength);
+            Preconditions.checkState(nlriLength == 0,
+                    "Remain NLRI length should be 0 instead of %s", nlriLength);
         }
 
         return fss;
@@ -612,7 +616,8 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
     }
 
     @Override
-    public final void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpReachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint)
+    public final void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpReachNlriBuilder builder,
+            @Nullable final PeerSpecificParserConstraint constraint)
         throws BGPParsingException {
         if (!nlri.isReadable()) {
             return;
index da2db9a9982c404bbb2d9f9862e2a5178211c860..4f6ccf0cc39a16f11b48a5042e8506e20b9f5b0c 100644 (file)
@@ -42,21 +42,16 @@ public final class FlowspecIpv4NlriParserHelper {
 
     public static void extractFlowspec(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
         if (fsType.getChild(AbstractFlowspecNlriParser.DEST_PREFIX_NID).isPresent()) {
-            fsBuilder.setFlowspecType(
-                new DestinationPrefixCaseBuilder()
-                    .setDestinationPrefix(
-                        new Ipv4Prefix((String) fsType.getChild(AbstractFlowspecNlriParser.DEST_PREFIX_NID).get().getValue())
-                    ).build()
-            );
+            fsBuilder.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix(
+                    new Ipv4Prefix((String) fsType.getChild(AbstractFlowspecNlriParser.DEST_PREFIX_NID).get()
+                            .getValue())).build());
         } else if (fsType.getChild(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID).isPresent()) {
-            fsBuilder.setFlowspecType(
-                new SourcePrefixCaseBuilder()
-                    .setSourcePrefix(
-                        new Ipv4Prefix((String) fsType.getChild(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID).get().getValue())
-                    ).build()
-            );
+            fsBuilder.setFlowspecType(new SourcePrefixCaseBuilder().setSourcePrefix(new Ipv4Prefix((String) fsType
+                    .getChild(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID).get().getValue())).build());
         } else if (fsType.getChild(PROTOCOL_IP_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new ProtocolIpCaseBuilder().setProtocolIps(createProtocolsIps((UnkeyedListNode) fsType.getChild(PROTOCOL_IP_NID).get())).build());
+            fsBuilder.setFlowspecType(new ProtocolIpCaseBuilder()
+                    .setProtocolIps(createProtocolsIps((UnkeyedListNode) fsType.getChild(PROTOCOL_IP_NID).get()))
+                    .build());
         }
     }
 
@@ -78,14 +73,13 @@ public final class FlowspecIpv4NlriParserHelper {
 
         for (final UnkeyedListEntryNode node : protocolIpsData.getValue()) {
             final ProtocolIpsBuilder ipsBuilder = new ProtocolIpsBuilder();
-            final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID);
-            if (opValue.isPresent()) {
-                ipsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
-            final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
-            if (valueNode.isPresent()) {
-                ipsBuilder.setValue((Short) valueNode.get().getValue());
-            }
+            final Optional<DataContainerChild<? extends PathArgument, ?>> opValue
+                    = node.getChild(AbstractFlowspecNlriParser.OP_NID);
+            opValue.ifPresent(dataContainerChild -> ipsBuilder.setOp(NumericOneByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
+            final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode
+                    = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
+            valueNode.ifPresent(dataContainerChild -> ipsBuilder.setValue((Short) dataContainerChild.getValue()));
             protocolIps.add(ipsBuilder.build());
         }
 
index c4c7e1aaeecc68eb5d3a7c145685aa3397d478e8..66a6a46695113b0c56ed97b63dfc37b7ceb5cbea 100644 (file)
@@ -44,21 +44,19 @@ public final class FlowspecIpv6NlriParserHelper {
 
     public static void extractFlowspec(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
         if (fsType.getChild(AbstractFlowspecNlriParser.DEST_PREFIX_NID).isPresent()) {
-            fsBuilder.setFlowspecType(
-                new DestinationIpv6PrefixCaseBuilder()
-                    .setDestinationPrefix(new Ipv6Prefix((String) fsType.getChild(AbstractFlowspecNlriParser.DEST_PREFIX_NID).get().getValue()))
-                    .build()
-            );
+            fsBuilder.setFlowspecType(new DestinationIpv6PrefixCaseBuilder()
+                    .setDestinationPrefix(new Ipv6Prefix((String) fsType
+                            .getChild(AbstractFlowspecNlriParser.DEST_PREFIX_NID).get().getValue())).build());
         } else if (fsType.getChild(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID).isPresent()) {
-            fsBuilder.setFlowspecType(
-                new SourceIpv6PrefixCaseBuilder()
-                    .setSourcePrefix(new Ipv6Prefix((String) fsType.getChild(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID).get().getValue()))
-                    .build()
-            );
+            fsBuilder.setFlowspecType(new SourceIpv6PrefixCaseBuilder().setSourcePrefix(new Ipv6Prefix((String) fsType
+                    .getChild(AbstractFlowspecNlriParser.SOURCE_PREFIX_NID).get().getValue())).build());
         } else if (fsType.getChild(NEXT_HEADER_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new NextHeaderCaseBuilder().setNextHeaders(createNextHeaders((UnkeyedListNode) fsType.getChild(NEXT_HEADER_NID).get())).build());
+            fsBuilder.setFlowspecType(new NextHeaderCaseBuilder()
+                    .setNextHeaders(createNextHeaders((UnkeyedListNode) fsType.getChild(NEXT_HEADER_NID).get()))
+                    .build());
         } else if (fsType.getChild(FLOW_LABEL_NID).isPresent()) {
-            fsBuilder.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(createFlowLabels((UnkeyedListNode) fsType.getChild(FLOW_LABEL_NID).get())).build());
+            fsBuilder.setFlowspecType(new FlowLabelCaseBuilder()
+                    .setFlowLabel(createFlowLabels((UnkeyedListNode) fsType.getChild(FLOW_LABEL_NID).get())).build());
         }
     }
 
@@ -83,14 +81,14 @@ public final class FlowspecIpv6NlriParserHelper {
 
         for (final UnkeyedListEntryNode node : nextHeadersData.getValue()) {
             final NextHeadersBuilder nextHeadersBuilder = new NextHeadersBuilder();
-            final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID);
-            if (opValue.isPresent()) {
-                nextHeadersBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
-            final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
-            if (valueNode.isPresent()) {
-                nextHeadersBuilder.setValue((Short) valueNode.get().getValue());
-            }
+            final Optional<DataContainerChild<? extends PathArgument, ?>> opValue
+                    = node.getChild(AbstractFlowspecNlriParser.OP_NID);
+            opValue.ifPresent(dataContainerChild -> nextHeadersBuilder.setOp(NumericOneByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
+            final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode
+                    = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
+            valueNode.ifPresent(dataContainerChild
+                    -> nextHeadersBuilder.setValue((Short) dataContainerChild.getValue()));
             nextHeaders.add(nextHeadersBuilder.build());
         }
 
@@ -102,14 +100,14 @@ public final class FlowspecIpv6NlriParserHelper {
 
         for (final UnkeyedListEntryNode node : flowLabelsData.getValue()) {
             final FlowLabelBuilder flowLabelsBuilder = new FlowLabelBuilder();
-            final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID);
-            if (opValue.isPresent()) {
-                flowLabelsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
-            }
-            final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
-            if (valueNode.isPresent()) {
-                flowLabelsBuilder.setValue((Long) valueNode.get().getValue());
-            }
+            final Optional<DataContainerChild<? extends PathArgument, ?>> opValue
+                    = node.getChild(AbstractFlowspecNlriParser.OP_NID);
+            opValue.ifPresent(dataContainerChild -> flowLabelsBuilder.setOp(NumericOneByteOperandParser
+                    .INSTANCE.create((Set<String>) dataContainerChild.getValue())));
+            final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode
+                    = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
+            valueNode.ifPresent(dataContainerChild
+                    -> flowLabelsBuilder.setValue((Long) dataContainerChild.getValue()));
             flowLabels.add(flowLabelsBuilder.build());
         }
 
index b70f54948379f7aad129369a7d961f335f0aeb67..ac41ef254c798815b9eff05def61939b7942e0f5 100644 (file)
@@ -9,9 +9,8 @@
 package org.opendaylight.protocol.bgp.inet.codec;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
@@ -133,10 +132,10 @@ public class Ipv4NlriParserTest {
                 .getDestinationType());
 
         assertEquals(this.ip4caseWD.hashCode(), b.getWithdrawnRoutes().getDestinationType().hashCode());
-        assertFalse(this.ip4caseWDWrong.hashCode() == b.getWithdrawnRoutes().getDestinationType().hashCode());
+        assertNotEquals(this.ip4caseWDWrong.hashCode(), b.getWithdrawnRoutes().getDestinationType().hashCode());
 
-        assertTrue(this.ip4caseWD.toString().equals(b.getWithdrawnRoutes().getDestinationType().toString()));
-        assertFalse(this.ip4caseWDWrong.toString().equals(b.getWithdrawnRoutes().getDestinationType().toString()));
+        assertEquals(this.ip4caseWD.toString(), b.getWithdrawnRoutes().getDestinationType().toString());
+        assertNotEquals(this.ip4caseWDWrong.toString(), b.getWithdrawnRoutes().getDestinationType().toString());
     }
 
     @Test
@@ -148,10 +147,10 @@ public class Ipv4NlriParserTest {
                 .getDestinationType());
 
         assertEquals(this.ip4caseAD.hashCode(), b.getAdvertizedRoutes().getDestinationType().hashCode());
-        assertFalse(this.ip4caseADWrong.hashCode() == b.getAdvertizedRoutes().getDestinationType().hashCode());
+        assertNotEquals(this.ip4caseADWrong.hashCode(), b.getAdvertizedRoutes().getDestinationType().hashCode());
 
-        assertTrue(this.ip4caseAD.toString().equals(b.getAdvertizedRoutes().getDestinationType().toString()));
-        assertFalse(this.ip4caseADWrong.toString().equals(b.getAdvertizedRoutes().getDestinationType().toString()));
+        assertEquals(this.ip4caseAD.toString(), b.getAdvertizedRoutes().getDestinationType().toString());
+        assertNotEquals(this.ip4caseADWrong.toString(), b.getAdvertizedRoutes().getDestinationType().toString());
     }
 
     @Test
index a4f35ddee57b3a319f32040e1eb8975b7a13ecfa..a0c8f35f5d6362b95abf5f63364d6a7a21d68c90 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.bgp.labeled.unicast;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.ArrayList;
@@ -57,10 +57,10 @@ public final class BgpPrefixSidTlvsTest {
 
         final LuOriginatorSrgbTlv parsed = parser.parseBgpPrefixSidTlv(serialized);
         assertEquals(tlv.getSrgbValue().size(), parsed.getSrgbValue().size());
-        assertTrue(tlv.getSrgbValue().get(0).getBase().equals(srgb1));
-        assertTrue(tlv.getSrgbValue().get(0).getRange().equals(srgb2));
-        assertTrue(tlv.getSrgbValue().get(1).getBase().equals(srgb2));
-        assertTrue(tlv.getSrgbValue().get(1).getRange().equals(srgb1));
+        assertEquals(tlv.getSrgbValue().get(0).getBase(), srgb1);
+        assertEquals(tlv.getSrgbValue().get(0).getRange(), srgb2);
+        assertEquals(tlv.getSrgbValue().get(1).getBase(), srgb2);
+        assertEquals(tlv.getSrgbValue().get(1).getRange(), srgb1);
 
         assertEquals(3, parser.getType());
     }
index 06900ab43b9abcdbfa2bb005cc2741a140712637..7a534919b24ead250c438928ce2051f6e152a201 100644 (file)
@@ -73,17 +73,21 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
     @VisibleForTesting
     public static final NodeIdentifier REMOTE_NODE_DESCRIPTORS_NID = new NodeIdentifier(RemoteNodeDescriptors.QNAME);
     @VisibleForTesting
-    public static final NodeIdentifier ADVERTISING_NODE_DESCRIPTORS_NID = new NodeIdentifier(AdvertisingNodeDescriptors.QNAME);
+    public static final NodeIdentifier ADVERTISING_NODE_DESCRIPTORS_NID
+            = new NodeIdentifier(AdvertisingNodeDescriptors.QNAME);
     @VisibleForTesting
     public static final NodeIdentifier PREFIX_DESCRIPTORS_NID = new NodeIdentifier(PrefixDescriptors.QNAME);
     @VisibleForTesting
     public static final NodeIdentifier LINK_DESCRIPTORS_NID = new NodeIdentifier(LinkDescriptors.QNAME);
     @VisibleForTesting
-    public static final NodeIdentifier PROTOCOL_ID_NID = new NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "protocol-id").intern());
+    public static final NodeIdentifier PROTOCOL_ID_NID = new NodeIdentifier(
+            QName.create(CLinkstateDestination.QNAME.getModule(), "protocol-id"));
     @VisibleForTesting
-    public static final NodeIdentifier IDENTIFIER_NID = new NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "identifier").intern());
+    public static final NodeIdentifier IDENTIFIER_NID = new NodeIdentifier(
+            QName.create(CLinkstateDestination.QNAME.getModule(), "identifier"));
     @VisibleForTesting
-    private static final NodeIdentifier DISTINGUISHER_NID = new NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "route-distinguisher").intern());
+    private static final NodeIdentifier DISTINGUISHER_NID = new NodeIdentifier(
+            QName.create(CLinkstateDestination.QNAME.getModule(), "route-distinguisher"));
     private final SimpleNlriTypeRegistry nlriTypeReg = SimpleNlriTypeRegistry.getInstance();
 
 
@@ -137,7 +141,8 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
 
     @Override
     public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
-        Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+        Preconditions.checkArgument(attribute instanceof Attributes,
+                "Attribute parameter is not a PathAttribute object.");
         final Attributes pathAttributes = (Attributes) attribute;
         final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
         final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
@@ -150,8 +155,10 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
 
     private void serializeWithDrawnRoutes(final WithdrawnRoutes withdrawnRoutes, final ByteBuf byteAggregator) {
         if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof DestinationLinkstateCase) {
-            final DestinationLinkstateCase linkstateCase = (DestinationLinkstateCase) withdrawnRoutes.getDestinationType();
-            for (final CLinkstateDestination cLinkstateDestination : linkstateCase.getDestinationLinkstate().getCLinkstateDestination()) {
+            final DestinationLinkstateCase linkstateCase
+                    = (DestinationLinkstateCase) withdrawnRoutes.getDestinationType();
+            for (final CLinkstateDestination cLinkstateDestination : linkstateCase.getDestinationLinkstate()
+                    .getCLinkstateDestination()) {
                 this.nlriTypeReg.serializeNlriType(cLinkstateDestination, byteAggregator);
             }
         }
@@ -159,12 +166,17 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
 
     private void serializeAdvertisedRoutes(final AdvertizedRoutes advertizedRoutes, final ByteBuf byteAggregator) {
         if (advertizedRoutes != null && advertizedRoutes.getDestinationType()
-            instanceof
-            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase) {
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase
-                linkstateCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase) advertizedRoutes.getDestinationType();
+                instanceof
+                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+                        .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase) {
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+                    .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase
+                    linkstateCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate
+                    .rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
+                    .DestinationLinkstateCase) advertizedRoutes.getDestinationType();
 
-            for (final CLinkstateDestination cLinkstateDestination : linkstateCase.getDestinationLinkstate().getCLinkstateDestination()) {
+            for (final CLinkstateDestination cLinkstateDestination : linkstateCase.getDestinationLinkstate()
+                    .getCLinkstateDestination()) {
                 this.nlriTypeReg.serializeNlriType(cLinkstateDestination, byteAggregator);
             }
         }
@@ -196,7 +208,8 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
         }
     }
 
-    public static CLinkstateDestination extractLinkstateDestination(final DataContainerNode<? extends PathArgument> linkstate) {
+    public static CLinkstateDestination extractLinkstateDestination(
+            final DataContainerNode<? extends PathArgument> linkstate) {
         final CLinkstateDestinationBuilder builder = new CLinkstateDestinationBuilder();
         serializeCommonParts(builder, linkstate);
 
@@ -215,7 +228,8 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
         return builder.build();
     }
 
-    private static void serializeNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
+    private static void serializeNodeDescriptor(final CLinkstateDestinationBuilder builder,
+            final ChoiceNode objectType) {
         final NodeCaseBuilder nodeBuilder = new NodeCaseBuilder();
         // node descriptors
         nodeBuilder.setNodeDescriptors(NodeNlriParser
@@ -223,51 +237,56 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer {
         builder.setObjectType(nodeBuilder.build());
     }
 
-    private static void serializeLocalNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
+    private static void serializeLocalNodeDescriptor(final CLinkstateDestinationBuilder builder,
+            final ChoiceNode objectType) {
         // link local node descriptors
         final LinkCaseBuilder linkBuilder = new LinkCaseBuilder();
 
-        linkBuilder.setLocalNodeDescriptors(NodeNlriParser.serializeLocalNodeDescriptors((ContainerNode) objectType.getChild(LOCAL_NODE_DESCRIPTORS_NID).get()));
+        linkBuilder.setLocalNodeDescriptors(NodeNlriParser.serializeLocalNodeDescriptors((ContainerNode) objectType
+                .getChild(LOCAL_NODE_DESCRIPTORS_NID).get()));
         // link remote node descriptors
         if (objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID).isPresent()) {
-            linkBuilder.setRemoteNodeDescriptors(NodeNlriParser.serializeRemoteNodeDescriptors((ContainerNode) objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID).get()));
+            linkBuilder.setRemoteNodeDescriptors(NodeNlriParser
+                    .serializeRemoteNodeDescriptors((ContainerNode) objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID)
+                            .get()));
         }
         // link descriptors
-        final Optional<DataContainerChild<? extends PathArgument, ?>> linkDescriptors = objectType.getChild(LINK_DESCRIPTORS_NID);
-        if (linkDescriptors.isPresent()) {
-            linkBuilder.setLinkDescriptors(LinkNlriParser.serializeLinkDescriptors((ContainerNode) linkDescriptors.get()));
-        }
+        final Optional<DataContainerChild<? extends PathArgument, ?>> linkDescriptors
+                = objectType.getChild(LINK_DESCRIPTORS_NID);
+        linkDescriptors.ifPresent(dataContainerChild -> linkBuilder.setLinkDescriptors(LinkNlriParser
+                .serializeLinkDescriptors((ContainerNode) dataContainerChild)));
         builder.setObjectType(linkBuilder.build());
     }
 
-    private static void serializeAdvertisedNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
+    private static void serializeAdvertisedNodeDescriptor(final CLinkstateDestinationBuilder builder,
+            final ChoiceNode objectType) {
         // prefix node descriptors
         final PrefixCaseBuilder prefixBuilder = new PrefixCaseBuilder();
-        prefixBuilder.setAdvertisingNodeDescriptors(NodeNlriParser.serializeAdvNodeDescriptors((ContainerNode) objectType.getChild(
-            ADVERTISING_NODE_DESCRIPTORS_NID).get()));
+        prefixBuilder.setAdvertisingNodeDescriptors(NodeNlriParser
+                .serializeAdvNodeDescriptors((ContainerNode) objectType.getChild(ADVERTISING_NODE_DESCRIPTORS_NID)
+                        .get()));
 
         // prefix descriptors
-        final Optional<DataContainerChild<? extends PathArgument, ?>> prefixDescriptors = objectType.getChild(PREFIX_DESCRIPTORS_NID);
-        if (prefixDescriptors.isPresent()) {
-            prefixBuilder.setPrefixDescriptors(AbstractPrefixNlriParser.serializePrefixDescriptors((ContainerNode) prefixDescriptors.get()));
-        }
+        final Optional<DataContainerChild<? extends PathArgument, ?>> prefixDescriptors
+                = objectType.getChild(PREFIX_DESCRIPTORS_NID);
+        prefixDescriptors.ifPresent(dataContainerChild -> prefixBuilder.setPrefixDescriptors(AbstractPrefixNlriParser
+                .serializePrefixDescriptors((ContainerNode) dataContainerChild)));
         builder.setObjectType(prefixBuilder.build());
     }
 
-    private static void serializeCommonParts(final CLinkstateDestinationBuilder builder, final DataContainerNode<? extends PathArgument> linkstate) {
+    private static void serializeCommonParts(final CLinkstateDestinationBuilder builder,
+            final DataContainerNode<? extends PathArgument> linkstate) {
         // serialize common parts
-        final Optional<DataContainerChild<? extends PathArgument, ?>> distinguisher = linkstate.getChild(DISTINGUISHER_NID);
-        if (distinguisher.isPresent()) {
-            builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(distinguisher.get().getValue()));
-        }
+        final Optional<DataContainerChild<? extends PathArgument, ?>> distinguisher
+                = linkstate.getChild(DISTINGUISHER_NID);
+        distinguisher.ifPresent(dataContainerChild -> builder.setRouteDistinguisher(RouteDistinguisherUtil
+                .parseRouteDistinguisher(dataContainerChild.getValue())));
         final Optional<DataContainerChild<? extends PathArgument, ?>> protocolId = linkstate.getChild(PROTOCOL_ID_NID);
         // DOM representation contains values as are in the model, not as are in generated enum
-        if (protocolId.isPresent()) {
-            builder.setProtocolId(ProtocolId.forValue(domProtocolIdValue((String) protocolId.get().getValue())));
-        }
+        protocolId.ifPresent(dataContainerChild -> builder.setProtocolId(ProtocolId
+                .forValue(domProtocolIdValue((String) dataContainerChild.getValue()))));
         final Optional<DataContainerChild<? extends PathArgument, ?>> identifier = linkstate.getChild(IDENTIFIER_NID);
-        if (identifier.isPresent()) {
-            builder.setIdentifier(new Identifier((BigInteger) identifier.get().getValue()));
-        }
+        identifier.ifPresent(dataContainerChild -> builder
+                .setIdentifier(new Identifier((BigInteger) dataContainerChild.getValue())));
     }
 }
index d8e91040589998e92427308cb0a7d52887f95fa1..14704f59c4f3ced773d5f5d3108672695ae24ff3 100644 (file)
@@ -85,19 +85,26 @@ public final class NodeNlriParser extends AbstractNlriTypeCodec {
     @VisibleForTesting
     private static final NodeIdentifier OSPF_PSEUDONODE_NID = new NodeIdentifier(OspfPseudonode.QNAME);
     @VisibleForTesting
-    public static final NodeIdentifier ISO_SYSTEM_NID = new NodeIdentifier(QName.create(NodeDescriptors.QNAME, "iso-system-id").intern());
+    public static final NodeIdentifier ISO_SYSTEM_NID = new NodeIdentifier(
+            QName.create(NodeDescriptors.QNAME.getModule(), "iso-system-id"));
     @VisibleForTesting
-    public static final NodeIdentifier ISIS_ROUTER_NID = new NodeIdentifier(QName.create(NodeDescriptors.QNAME, "is-is-router-identifier").intern());
+    public static final NodeIdentifier ISIS_ROUTER_NID = new NodeIdentifier(
+            QName.create(NodeDescriptors.QNAME.getModule(),"is-is-router-identifier"));
     @VisibleForTesting
-    public static final NodeIdentifier PSN_NID = new NodeIdentifier(QName.create(NodeDescriptors.QNAME, "psn").intern());
+    public static final NodeIdentifier PSN_NID = new NodeIdentifier(
+            QName.create(NodeDescriptors.QNAME.getModule(),"psn"));
     @VisibleForTesting
-    public static final NodeIdentifier OSPF_ROUTER_NID = new NodeIdentifier(QName.create(NodeDescriptors.QNAME, "ospf-router-id").intern());
-    private static final NodeIdentifier LAN_IFACE_NID = new NodeIdentifier(QName.create(NodeDescriptors.QNAME, "lan-interface").intern());
+    public static final NodeIdentifier OSPF_ROUTER_NID = new NodeIdentifier(
+            QName.create(NodeDescriptors.QNAME.getModule(),"ospf-router-id"));
+    private static final NodeIdentifier LAN_IFACE_NID = new NodeIdentifier(
+            QName.create(NodeDescriptors.QNAME.getModule(),"lan-interface"));
 
     @Override
     protected ObjectType parseObjectType(final ByteBuf buffer) {
         final NodeCaseBuilder builder = new NodeCaseBuilder();
-        builder.setNodeDescriptors(new NodeDescriptorsBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.NodeIdentifier) SimpleNlriTypeRegistry.getInstance().parseTlv(buffer)).build());
+        builder.setNodeDescriptors(new NodeDescriptorsBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.params
+                .xml.ns.yang.bgp.linkstate.rev180329.NodeIdentifier) SimpleNlriTypeRegistry.getInstance()
+                .parseTlv(buffer)).build());
         return builder.build();
     }
 
@@ -125,7 +132,8 @@ public final class NodeNlriParser extends AbstractNlriTypeCodec {
         if (pseudoIsisNode.getChild(ISIS_ROUTER_NID).isPresent()) {
             final ContainerNode isisRouterNid = (ContainerNode) pseudoIsisNode.getChild(ISIS_ROUTER_NID).get();
             if (isisRouterNid.getChild(ISO_SYSTEM_NID).isPresent()) {
-                isisRouterId.setIsoSystemId(new IsoSystemIdentifier((byte[]) isisRouterNid.getChild(ISO_SYSTEM_NID).get().getValue()));
+                isisRouterId.setIsoSystemId(new IsoSystemIdentifier((byte[]) isisRouterNid.getChild(ISO_SYSTEM_NID)
+                        .get().getValue()));
             }
         }
 
@@ -155,7 +163,8 @@ public final class NodeNlriParser extends AbstractNlriTypeCodec {
         final OspfPseudonodeCaseBuilder builder = new OspfPseudonodeCaseBuilder();
         final OspfPseudonodeBuilder nodeBuilder = new OspfPseudonodeBuilder();
         if (ospfPseudonode.getChild(LAN_IFACE_NID).isPresent()) {
-            nodeBuilder.setLanInterface(new OspfInterfaceIdentifier((Long)ospfPseudonode.getChild(LAN_IFACE_NID).get().getValue()));
+            nodeBuilder.setLanInterface(new OspfInterfaceIdentifier((Long)ospfPseudonode.getChild(LAN_IFACE_NID)
+                    .get().getValue()));
         }
         if (ospfPseudonode.getChild(OSPF_ROUTER_NID).isPresent()) {
             nodeBuilder.setOspfRouterId((Long)ospfPseudonode.getChild(OSPF_ROUTER_NID).get().getValue());
@@ -166,7 +175,8 @@ public final class NodeNlriParser extends AbstractNlriTypeCodec {
 
     private static CRouterIdentifier serializeRouterId(final ContainerNode descriptorsData) {
         CRouterIdentifier cRouterId = null;
-        final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRouterId = descriptorsData.getChild(ROUTER_NID);
+        final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRouterId
+                = descriptorsData.getChild(ROUTER_NID);
         if (maybeRouterId.isPresent()) {
             final ChoiceNode routerId = (ChoiceNode) maybeRouterId.get();
             if (routerId.getChild(ISIS_NODE_NID).isPresent()) {
@@ -183,43 +193,34 @@ public final class NodeNlriParser extends AbstractNlriTypeCodec {
     }
 
     private static AsNumber serializeAsNumber(final ContainerNode descriptorsData) {
-        final Optional<DataContainerChild<? extends PathArgument, ?>> asNumber = descriptorsData.getChild(AS_NUMBER_NID);
-        if (asNumber.isPresent()) {
-            return new AsNumber((Long) asNumber.get().getValue());
-        }
-        return null;
+        final Optional<DataContainerChild<? extends PathArgument, ?>> asNumber
+                = descriptorsData.getChild(AS_NUMBER_NID);
+        return asNumber.map(dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
     }
 
     private static DomainIdentifier serializeDomainId(final ContainerNode descriptorsData) {
         final Optional<DataContainerChild<? extends PathArgument, ?>> domainId = descriptorsData.getChild(DOMAIN_NID);
-        if (domainId.isPresent()) {
-            return new DomainIdentifier((Long) domainId.get().getValue());
-        }
-        return null;
+        return domainId.map(dataContainerChild
+                -> new DomainIdentifier((Long) dataContainerChild.getValue())).orElse(null);
     }
 
     private static AreaIdentifier serializeAreaId(final ContainerNode descriptorsData) {
         final Optional<DataContainerChild<? extends PathArgument, ?>> areaId = descriptorsData.getChild(AREA_NID);
-        if (areaId.isPresent()) {
-            return new AreaIdentifier((Long) areaId.get().getValue());
-        }
-        return null;
+        return areaId.map(dataContainerChild
+                -> new AreaIdentifier((Long) dataContainerChild.getValue())).orElse(null);
     }
 
     private static Ipv4Address serializeBgpRouterId(final ContainerNode descriptorsData) {
-        final Optional<DataContainerChild<? extends PathArgument, ?>> bgpRouterId = descriptorsData.getChild(BGP_ROUTER_NID);
-        if (bgpRouterId.isPresent()) {
-            return new Ipv4Address((String) bgpRouterId.get().getValue());
-        }
-        return null;
+        final Optional<DataContainerChild<? extends PathArgument, ?>> bgpRouterId
+                = descriptorsData.getChild(BGP_ROUTER_NID);
+        return bgpRouterId.map(dataContainerChild
+                -> new Ipv4Address((String) dataContainerChild.getValue())).orElse(null);
     }
 
     private static AsNumber serializeMemberAsn(final ContainerNode descriptorsData) {
-        final Optional<DataContainerChild<? extends PathArgument, ?>> memberAsn = descriptorsData.getChild(MEMBER_ASN_NID);
-        if (memberAsn.isPresent()) {
-            return new AsNumber((Long) memberAsn.get().getValue());
-        }
-        return null;
+        final Optional<DataContainerChild<? extends PathArgument, ?>> memberAsn
+                = descriptorsData.getChild(MEMBER_ASN_NID);
+        return memberAsn.map(dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
     }
 
     static LocalNodeDescriptors serializeLocalNodeDescriptors(final ContainerNode descriptorsData) {
index 31d704ecaa61e742ca3d03230a17a0146f9964d0..725bbec2e3856c821772df70eb2597ca4a88fb6b 100644 (file)
@@ -19,9 +19,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 
-public final class OspfRouteTlvParser implements LinkstateTlvParser<OspfRouteType>, LinkstateTlvParser.LinkstateTlvSerializer<OspfRouteType> {
+public final class OspfRouteTlvParser implements LinkstateTlvParser<OspfRouteType>,
+        LinkstateTlvParser.LinkstateTlvSerializer<OspfRouteType> {
 
-    public static final QName OSPF_ROUTE_TYPE_QNAME = QName.create(PrefixDescriptors.QNAME, "ospf-route-type").intern();
+    public static final QName OSPF_ROUTE_TYPE_QNAME =
+            QName.create(PrefixDescriptors.QNAME.getModule(), "ospf-route-type");
     public static final NodeIdentifier OSPF_ROUTE_NID = new NodeIdentifier(OspfRouteTlvParser.OSPF_ROUTE_TYPE_QNAME);
     private static final int OSPF_ROUTE_TYPE = 264;
 
@@ -46,11 +48,11 @@ public final class OspfRouteTlvParser implements LinkstateTlvParser<OspfRouteTyp
     }
 
     public static OspfRouteType serializeModel(final ContainerNode prefixDesc) {
-        final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> ospfRoute = prefixDesc.getChild(OSPF_ROUTE_NID);
-        if (ospfRoute.isPresent()) {
-            return OspfRouteType.forValue(domOspfRouteTypeValue((String) ospfRoute.get().getValue()));
-        }
-        return null;
+        final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> ospfRoute
+                = prefixDesc.getChild(OSPF_ROUTE_NID);
+        return ospfRoute.map(dataContainerChild
+                -> OspfRouteType.forValue(domOspfRouteTypeValue((String) dataContainerChild.getValue())))
+                .orElse(null);
     }
 
 
index 3840ce9dcf40fa0f87ff817810cb3a9741d0f420..d22a05200adbbab06202c0f87abfb2483b568a28 100644 (file)
@@ -36,7 +36,7 @@ final class ConditionsRegistryImpl {
             = new HashMap<>();
     //TODO Implement match prefix
     //private final GenericConditionPolicyHandler genericConditionHandler;
-    private BgpConditionsRegistry bgpConditionsRegistry = new BgpConditionsRegistry();
+    private final BgpConditionsRegistry bgpConditionsRegistry = new BgpConditionsRegistry();
 
     ConditionsRegistryImpl(final DataBroker databroker) {
     //    this.genericConditionHandler = new GenericConditionPolicyHandler(databroker);
index 7ed5d40e6ff4b3bb06097d45c063b3f25948ab4f..c675662b3d84569f5f877307c2106753eba83344 100644 (file)
@@ -325,13 +325,10 @@ public final class NeighborUtil {
     private static AfiSafi buildAfiSafi(@Nonnull final BGPAfiSafiState neighbor,
             @Nonnull final TablesKey tablesKey, @Nonnull final BGPTableTypeRegistryConsumer bgpTableTypeRegistry) {
         final Optional<Class<? extends AfiSafiType>> afiSafi = bgpTableTypeRegistry.getAfiSafiType(tablesKey);
-        if (!afiSafi.isPresent()) {
-            return null;
-        }
-
-        return new AfiSafiBuilder().setAfiSafiName(afiSafi.get())
+        return afiSafi.map(aClass -> new AfiSafiBuilder().setAfiSafiName(aClass)
                 .setState(buildAfiSafiState(neighbor, tablesKey, neighbor.isAfiSafiSupported(tablesKey)))
-                .setGracefulRestart(buildAfiSafiGracefulRestartState(neighbor, tablesKey)).build();
+                .setGracefulRestart(buildAfiSafiGracefulRestartState(neighbor, tablesKey)).build()).orElse(null);
+
     }
 
     private static org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi
index ad43dbc3651c38453bba44c771e4f7ed3c3ba324..0e30ca10a3d227b7bb034ff13b23344f572b5124 100644 (file)
@@ -194,7 +194,7 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
     private InMemoryDOMDataStore spiedOperStore;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         MockitoAnnotations.initMocks(this);
 
         doReturn(Optional.of(IPV4UNICAST.class))
@@ -435,9 +435,7 @@ public class StateProviderImplTest extends ConstantSchemaAbstractDataBrokerTest
             }).when(mockTxChain).newWriteOnlyTransaction();
 
             return mockTxChain;
-        }).doAnswer(invocation -> {
-            return realOperStore.createTransactionChain();
-        }).when(spiedOperStore).createTransactionChain();
+        }).doAnswer(invocation -> realOperStore.createTransactionChain()).when(spiedOperStore).createTransactionChain();
 
         int timerInterval = 1;
         try (StateProviderImpl stateProvider = new StateProviderImpl(getDataBroker(), timerInterval, tableTypeRegistry,
index fd75c0cc3e810a4d5cf9e046e6f1c58a69ba3bcc..9728677b798c7fee253454c325814b1ef5862096 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.parser;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -83,6 +84,6 @@ public class APITest {
                 BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
         params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
         final Open open1 = new OpenBuilder().setBgpParameters(params).build();
-        assertEquals(true, BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
+        assertTrue(BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
     }
 }
index e04f38d6e4bb3c0524d428abf317f529e61a245f..eba8c4d3545eb0ac61dd1ddf504e1507458e0431 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.protocol.bgp.parser;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.fail;
 
@@ -41,7 +41,7 @@ public class TableTypeTest {
             assertEquals("Subsequent address family may not be null", e.getMessage());
         }
 
-        assertFalse(tt1.equals(tt2));
+        assertNotEquals(tt1, tt2);
         assertNotSame(tt1.hashCode(), tt2.hashCode());
         assertEquals(tt1.toString(), tt1.toString());
         assertNotSame(tt1.getAfi(), tt2.getAfi());
index b6261dbe5aba34f99634672402795a87382878fe..7fcc312d34d988ac25cfb0f81684c1c4ed984933 100644 (file)
@@ -35,19 +35,19 @@ public final class MultiProtocolCapabilityHandler implements CapabilityParser, C
     private final AddressFamilyRegistry afiReg;
     private final SubsequentAddressFamilyRegistry safiReg;
 
-    public MultiProtocolCapabilityHandler(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
+    public MultiProtocolCapabilityHandler(final AddressFamilyRegistry afiReg,
+            final SubsequentAddressFamilyRegistry safiReg) {
         this.afiReg = requireNonNull(afiReg);
         this.safiReg = requireNonNull(safiReg);
     }
 
     @Override
     public CParameters parseCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
-        final Optional<BgpTableType> parsedAfiSafiOptional = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(buffer, this.afiReg, this.safiReg);
-        if (!parsedAfiSafiOptional.isPresent()) {
-            return null;
-        }
-        return new CParametersBuilder().addAugmentation(CParameters1.class,new CParameters1Builder().setMultiprotocolCapability(
-            new MultiprotocolCapabilityBuilder(parsedAfiSafiOptional.get()).build()).build()).build();
+        final Optional<BgpTableType> parsedAfiSafiOptional = MultiprotocolCapabilitiesUtil
+                .parseMPAfiSafi(buffer, this.afiReg, this.safiReg);
+        return parsedAfiSafiOptional.map(bgpTableType -> new CParametersBuilder()
+                .addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(
+                new MultiprotocolCapabilityBuilder(bgpTableType).build()).build()).build()).orElse(null);
     }
 
     @Override
@@ -59,7 +59,8 @@ public final class MultiProtocolCapabilityHandler implements CapabilityParser, C
         final MultiprotocolCapability mp = capability.getAugmentation(CParameters1.class).getMultiprotocolCapability();
 
         final ByteBuf capBuffer = Unpooled.buffer();
-        MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, mp.getAfi(), mp.getSafi(), capBuffer);
+        MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, mp.getAfi(),
+                mp.getSafi(), capBuffer);
 
         CapabilityUtil.formatCapability(CODE, capBuffer, byteAggregator);
     }
index 77f37cbb416434632e7aaac90843e84f389b7150..c4e2a56cfc2c03e27ca17510aed65ccb1dc8a970 100644 (file)
@@ -78,9 +78,9 @@ public class BGPParserTest {
      */
     static final List<byte[]> inputBytes = new ArrayList<>();
 
-    private static int COUNTER = 7;
+    private static final int COUNTER = 7;
 
-    private static int MAX_SIZE = 300;
+    private static final int MAX_SIZE = 300;
 
     private static BGPUpdateMessageParser updateParser;
 
index 9196e869960dc3ce71fec1dd7f4ad2216e5aa9d6..0ab58322d4c7f13c734ad954de2b4c2419d57f8f 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.parser.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotSame;
 
 import java.lang.reflect.Constructor;
@@ -64,7 +65,7 @@ public class ComplementaryTest {
 
         assertEquals(0, tlv3.getRestartTime().intValue());
 
-        assertFalse(tlv1.equals(tlv2));
+        assertNotEquals(tlv1, tlv2);
 
         assertNotSame(tlv1.hashCode(), tlv3.hashCode());
 
index deca4e112985a9f5c73cc6a7ba556c5a36ca868d..df5b96adc02b345ba1f9400d99b5de263dac9953 100644 (file)
@@ -51,7 +51,7 @@ public class BaseBestPathTest {
     public void testHashCodeAndEqual() {
         assertTrue(this.baseBestPath.equals(this.baseBestPathCopy)
                 && this.baseBestPathCopy.equals(this.baseBestPath));
-        assertTrue(this.baseBestPath.hashCode() == this.baseBestPathCopy.hashCode());
+        assertEquals(this.baseBestPath.hashCode(), this.baseBestPathCopy.hashCode());
     }
 
     @Test
index 8cf798ac0c7c12d81fc065ab9a05a89191ced4f4..cb3bdf5cbf855af9cd1a9a4c9eb4bb1f8d5ca1bb 100644 (file)
@@ -131,9 +131,7 @@ public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTre
         this.writerChain = this.rib.createPeerDOMChain(this);
 
         final Set<TablesKey> localTables = this.rib.getLocalTablesKeys();
-        localTables.forEach(tablesKey -> {
-            this.supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey));
-        });
+        localTables.forEach(tablesKey -> this.supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey)));
         setAdvertizedGracefulRestartTableTypes(Collections.emptyList());
 
         this.adjRibInWriter = AdjRibInWriter.create(this.rib.getYangRibId(), PeerRole.Internal, this.writerChain);
index 375b577aa58249f3cdb4ce5efd7a664d292576af..eda7ecaf8cb772c04cf92de061274e2318015d54 100644 (file)
@@ -118,7 +118,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
     @GuardedBy("this")
     private BGPSession session;
     @GuardedBy("this")
-    private DOMTransactionChain chain;
+    private final DOMTransactionChain chain;
     @GuardedBy("this")
     private AdjRibInWriter ribWriter;
     @GuardedBy("this")
index 64167cd1489d1bf057d74fbf79befbe5e50e20ee..7873b3a2d5b3eb12855631097f56ce6f6231997b 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 
 public final class BGPPeerTrackerImpl implements BGPPeerTracker {
     @GuardedBy("this")
-    private Map<PeerId, Peer> peers = new HashMap<>();
+    private final Map<PeerId, Peer> peers = new HashMap<>();
     private ImmutableList<Peer> peersList;
 
     @Override
index a7358453f7c95afc011fe70cb6cee00d6e42ede5..e3547f881c640900b6dd221c62dfa9313e6a7f5a 100644 (file)
@@ -216,7 +216,7 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
     }
 
     private final class BgpPeerSingletonService implements BGPPeerStateConsumer {
-        private boolean activeConnection;
+        private final boolean activeConnection;
         private final BGPDispatcher dispatcher;
         private final InetSocketAddress inetAddress;
         private final int retryTimer;
index ec403dd6f4d195a93604e1c794ab1e957c743794..2a96ad886aaeaf977fd4c94a984fff606ff9d188 100644 (file)
@@ -80,7 +80,7 @@ public final class RibImpl implements RIB, BGPRibStateConsumer, AutoCloseable {
     private Ipv4Address routerId;
 
     private ClusterIdentifier clusterId;
-    private DataBroker dataBroker;
+    private final DataBroker dataBroker;
 
     public RibImpl(
             final RIBExtensionConsumerContext contextProvider,
index 63de26aed259f37523af6da86370be34b1da9bdf..e3f8b1f1da6fb2821b6008921bff52bbe5709e96 100644 (file)
@@ -135,7 +135,7 @@ public abstract class AbstractAddPathTest extends DefaultRibPoliciesMockTest {
     private NioEventLoopGroup boss;
     private org.opendaylight.protocol.bgp.inet.BGPActivator inetActivator;
     protected StrictBGPPeerRegistry serverRegistry;
-    protected BGPPeerTrackerImpl peerTracker = new BGPPeerTrackerImpl();
+    protected final BGPPeerTrackerImpl peerTracker = new BGPPeerTrackerImpl();
     protected CodecsRegistryImpl codecsRegistry;
 
     @Before
index 11e1d73eb62c0b74082fbd166b04b19d5792e64c..86f3ce7f0227282938e8494a1969ade9d249aab9 100644 (file)
@@ -136,7 +136,7 @@ public class AbstractRIBTestSetup extends DefaultRibPoliciesMockTest {
 
     @Mock
     private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
-    private BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
+    private final BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
 
     private static ModuleInfoBackedContext createClassLoadingStrategy() {
         final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
index 6482b91aa68ff5f9ae1aed6b3683d6dd5bf1c9ac..4b1e0859b48a2598c02ea228e6b62f47e0e666a8 100755 (executable)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.bgp.rib.impl;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
@@ -73,7 +74,7 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
 
     @Mock
     private BGPDispatcher dispatcher;
-    private BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
+    private final BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
     private CodecsRegistryImpl codecsRegistry;
 
     @Before
@@ -163,7 +164,7 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
                 for (final Tables table : tables) {
                     if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
                         found = true;
-                        assertTrue(Boolean.valueOf(true).equals(table.getAttributes().isUptodate()));
+                        assertEquals(Boolean.valueOf(true), table.getAttributes().isUptodate());
                     }
                 }
                 assertTrue(found);
index 94b987f6875b08bc6b28db0f33b708df60e1aa9a..a20fc7b94572235759f275e4473eb0ee1c69921b 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
 
 import com.google.common.primitives.UnsignedInteger;
 import org.junit.Test;
@@ -28,10 +28,10 @@ public class RouteUpdateKeyTest {
         final RouteUpdateKey rk = new RouteUpdateKey(PEER_ID, PREFIX);
         assertEquals(PEER_ID, rk.getPeerId());
         assertEquals(PREFIX, rk.getRouteId());
-        assertTrue(rk.equals(new RouteUpdateKey(PEER_ID, PREFIX)));
-        assertTrue(rk.equals(rk));
+        assertEquals(rk, new RouteUpdateKey(PEER_ID, PREFIX));
+        assertEquals(rk, rk);
         assertFalse(rk.equals(null));
-        assertFalse(rk.equals(new RouteUpdateKey(PEER_ID_2, PREFIX)));
-        assertFalse(rk.equals(new RouteUpdateKey(PEER_ID_2, PREFIX_2)));
+        assertNotEquals(rk, new RouteUpdateKey(PEER_ID_2, PREFIX));
+        assertNotEquals(rk, new RouteUpdateKey(PEER_ID_2, PREFIX_2));
     }
 }
\ No newline at end of file
index 04e9908cacde22ea62dac179860150c43e8453fe..d5dfd775ed058996de177b8872cf80505bc99175 100644 (file)
@@ -90,7 +90,7 @@ public final class SimpleSessionListener implements BGPSessionListener, Listener
     }
 
     BGPSessionImpl getSession() {
-        Assert.assertEquals("Session up", true, Uninterruptibles.awaitUninterruptibly(this.sessionLatch, 10, TimeUnit.SECONDS));
+        Assert.assertTrue("Session up", Uninterruptibles.awaitUninterruptibly(this.sessionLatch, 10, TimeUnit.SECONDS));
         return (BGPSessionImpl) this.session;
     }
 
index f755498a15e5c98bed9ff31c23d52d930e7b025d..fee0253802781ab789ef7103ea32eac8b227ae57 100644 (file)
@@ -86,7 +86,7 @@ class AbstractConfig extends DefaultRibPoliciesMockTest {
     protected PeerGroupConfigLoader peerGroupLoader;
     @Mock
     private DOMDataTreeChangeService dataTreeChangeService;
-    private BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
+    private final BGPPeerTracker peerTracker = new BGPPeerTrackerImpl();
 
     @Before
     public void setUp() throws Exception {
index 7d3d3ac7cd9057bba3eac6bb2c7aa845f0c210c5..b3a850ba9ad7e645ba719326a09b52aba5c01f3a 100644 (file)
@@ -95,7 +95,7 @@ public class RIBSupportTest extends AbstractConcurrentDataBrokerTest {
     private DataTreeCandidateNode subTree;
     private DOMDataWriteTransaction tx;
     private ContainerNode nlri;
-    private Map<YangInstanceIdentifier, NormalizedNode<?, ?>> routesMap = new HashMap<>();
+    private final Map<YangInstanceIdentifier, NormalizedNode<?, ?>> routesMap = new HashMap<>();
     private ContainerNode attributes;
     private MapEntryNode mapEntryNode;
     private BindingToNormalizedNodeCodec mappingService;
index d920b7e25f9b9960740b6b9fa1fa0c230df1fb17..6b149f65a64798cf049890a681374263acdc0884 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 
 public class RouterIdsTest {
 
-    private UnsignedInteger unsignedRouterId = UnsignedInteger.valueOf(707406378);
-    private PeerId peerID = new PeerId("bgp://42.42.42.42");
+    private final UnsignedInteger unsignedRouterId = UnsignedInteger.valueOf(707406378);
+    private final PeerId peerID = new PeerId("bgp://42.42.42.42");
 
     @Test
     public void testRouterIdForAddress() throws Exception {
index 81ba926f19e7fd612c6bf832c1e4d6272f89dacc..64ac7dae2c0dca0dd49d72ffc1b3a5951a68961f 100644 (file)
@@ -70,7 +70,7 @@ public abstract class AbstractTopologyBuilder<T extends Route> implements Cluste
     private ListenerRegistration<AbstractTopologyBuilder<T>> listenerRegistration = null;
     @GuardedBy("this")
     private BindingTransactionChain chain = null;
-    private AtomicBoolean closed = new AtomicBoolean(false);
+    private final AtomicBoolean closed = new AtomicBoolean(false);
     @GuardedBy("this")
     @VisibleForTesting
     protected long listenerScheduledRestartTime = 0;
index 62373d6297674d73ccfdec262a75a5af13793146..78ee0e4621e0cc941b7cdf0a895dbbfca4352f04 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.bgpcep.bgp.topology.provider;
 
-import com.google.common.collect.Lists;
 import com.google.common.io.BaseEncoding;
 import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.IsisAreaIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.NodeFlagBits;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.NodeIdentifier;
@@ -208,7 +208,8 @@ public final class ProtocolUtil {
 
 
     private static List<IsoNetId> toIsoNetIds(final List<IsisAreaIdentifier> areaIds, final String systemId) {
-        return Lists.transform(areaIds, input -> new IsoNetId(UriBuilder.toIsoNetId(input, systemId)));
+        return areaIds.stream().map(input -> new IsoNetId(UriBuilder.toIsoNetId(input, systemId)))
+                .collect(Collectors.toList());
     }
 
     private static List<Short> nodeMultiTopology(final List<TopologyIdentifier> list) {
index efba6e387b754ea5ed5879273c26b9e641bfda09..e11e46112f9ebdd2dc3e2358e0de6b9a78a86c4b 100755 (executable)
@@ -129,7 +129,7 @@ public class LinkstateTopologyBuilderTest extends AbstractTopologyBuilderTest {
             .child(Tables.class, new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class))
             .build();
         this.linkstateRouteIID = path.builder().child((Class) LinkstateRoutes.class)
-            .child(LinkstateRoute.class, new LinkstateRouteKey(new PathId(0L), LINKSTATE_ROUTE_KEY.toString()))
+            .child(LinkstateRoute.class, new LinkstateRouteKey(new PathId(0L), LINKSTATE_ROUTE_KEY))
                 .build();
 
     }
@@ -334,7 +334,7 @@ public class LinkstateTopologyBuilderTest extends AbstractTopologyBuilderTest {
         Thread.sleep(LISTENER_RESTART_TIME);
         // manually invoke onTransactionChainFailed() to have the listener restart scheduled again
         spiedLinkstateTopologyBuilder.onTransactionChainFailed(null, null, null);
-        assertTrue(spiedLinkstateTopologyBuilder.listenerScheduledRestartTime == listenerScheduledRestartTime
+        assertEquals(spiedLinkstateTopologyBuilder.listenerScheduledRestartTime, listenerScheduledRestartTime
                 + LISTENER_RESTART_TIME);
         verify(spiedLinkstateTopologyBuilder, times(5)).restartTransactionChainOnDemand();
         verify(spiedLinkstateTopologyBuilder, times(3)).scheduleListenerRestart();
index 698e9ad6a7ab4f5d04ddda19f23c39ee8119311d..6a91e809b16f2ee6631686e3bb5ea5bea019a45e 100644 (file)
@@ -99,7 +99,7 @@ public class BmpDispatcherImpl implements BmpDispatcher {
         private final BmpSessionListenerFactory slf;
         private final KeyMapping keys;
         private long delay;
-        private Timer timer = new Timer();
+        private final Timer timer = new Timer();
 
         BootstrapListener(final Bootstrap bootstrap,
                 final InetSocketAddress remoteAddress, final BmpSessionListenerFactory slf, final KeyMapping keys) {
index f4ea2c72e9338f97370ed42895f9365c7c78003a..e83226f3c6efcd7f70cadab02b34d9aba33f6592 100644 (file)
@@ -84,8 +84,8 @@ final class BmpMockDispatcher implements AutoCloseable {
         private final Bootstrap bootstrap;
         private final InetSocketAddress remoteAddress;
         private final SocketAddress localAddress;
-        private long delay;
-        private Timer timer = new Timer();
+        private final long delay;
+        private final Timer timer = new Timer();
 
         BootstrapListener(final Bootstrap bootstrap, final SocketAddress localAddress,
                 final InetSocketAddress remoteAddress) {
index 8e7fe8099d9ef6ab347574420e19d82881872468..4fb479f5d381800bd6e8476ecafda0ae2a6665d0 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 public final class BmpMockSessionListener implements BmpSessionListener {
     private final LongAdder counter = new LongAdder();
     @GuardedBy("this")
-    private AtomicBoolean up = new AtomicBoolean(false);
+    private final AtomicBoolean up = new AtomicBoolean(false);
 
     @Override
     public void onSessionUp(final BmpSession session) {
index 7e00539afbd0143db614eddb9b20aa5f4b071958..a97b854055fbb002474e6efebef85b57c6709e73 100644 (file)
@@ -99,7 +99,7 @@ public class AbstractBmpMessageWithTlvParserTest {
 
         @Override
         protected void addTlv(final TlvsBuilder builder, final Tlv tlv) {
-            if (tlv != null && tlv instanceof DescriptionTlv) {
+            if (tlv instanceof DescriptionTlv) {
                 builder.setDescriptionTlv((DescriptionTlv) tlv);
             }
         }
index bd5975eb6ab60519bec4c9cbed8a458091bf8691..9d4d9e98cb79555a958cfb41a5e7557c1f43555f 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.protocol.concepts;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.not;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertThat;
 
 import java.util.HashSet;
@@ -53,7 +53,7 @@ public class ASNumberTest {
         assertThat(this.asn1, not(equalTo(this.asn3)));
         assertThat(this.asn1, not(equalTo(this.asn4)));
         assertThat(this.asn1, not(equalTo(new Object())));
-        assertFalse(this.asn1.equals(new Object()));
+        assertNotEquals(this.asn1, new Object());
     }
 
     @Test
index 67e382b6c78189af6b45d7dbbf96bdb32443bd8b..a841e1230c308ffd544c94df3ee7d2b0aaf64908 100644 (file)
             <classifier>features</classifier>
             <type>xml</type>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>odl-bgpcep-bgp-mvpn</artifactId>
-            <classifier>features</classifier>
-            <type>xml</type>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>odl-bgpcep-bgp-l3vpn</artifactId>
index 41bbf871312cf118ba3c10878d02c680a1cf413f..03ff2ae7d9d615bcf8ea72a2085e6ea829dd9b11 100644 (file)
@@ -36,7 +36,7 @@ public class RROIpv4PrefixSubobjectParser implements RROSubobjectParser, RROSubo
     private static final int PREFIX_F_LENGTH = 1;
     private static final int FLAGS_SIZE = 8;
 
-    private static final int PREFIX4_F_OFFSET = 0 + Ipv4Util.IP4_LENGTH;
+    private static final int PREFIX4_F_OFFSET = Ipv4Util.IP4_LENGTH;
 
     private static final int CONTENT4_LENGTH = Ipv4Util.IP4_LENGTH + PREFIX_F_LENGTH + FLAGS_SIZE / Byte.SIZE;
 
index 87eff40e6e57a2928388fd766bd4980eb9295f59..5c9107cb8e948e66cca3b49b3f31319d3e430ff8 100644 (file)
@@ -90,7 +90,7 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
 
     // True if the listener should not be notified about events
     @GuardedBy("this")
-    private AtomicBoolean closed = new AtomicBoolean(false);
+    private final AtomicBoolean closed = new AtomicBoolean(false);
 
     private final Channel channel;
 
index ad3bdd66c045b5916f3b65a8aa36e3193bb3eab7..ff68b2d2bb1f10067e805fd02127c13b398e172d 100644 (file)
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SimpleSessionListener implements PCEPSessionListener {
 
-    public List<Message> messages = Lists.newArrayList();
+    public final List<Message> messages = Lists.newArrayList();
 
     public boolean up = false;
 
index 9a90e7ccfff36a2ddad2a6e90663df955e275e78..8036bd6e0d1b81225fae77ebc93ffea3c19f6730 100644 (file)
@@ -71,8 +71,7 @@ public final class TestingSessionListener implements PCEPSessionListener, Listen
     }
 
     public PCEPSession getSession() {
-        Assert.assertEquals("Session up", true,
-                Uninterruptibles.awaitUninterruptibly(this.sessionLatch, 10, TimeUnit.SECONDS));
+        Assert.assertTrue("Session up", Uninterruptibles.awaitUninterruptibly(this.sessionLatch, 10, TimeUnit.SECONDS));
         return this.session;
     }
 
index 056d4329ecf62e85956cbdf16c9189da9319bbad..1ffd93de44a7d73a3b1cd911158650857aa926f1 100644 (file)
@@ -36,7 +36,7 @@ public class APITest {
         assertNull(header.isProcessingRule());
 
         assertEquals(new ObjectHeaderImpl(null, true).hashCode(),  header.hashCode());
-        assertTrue(new ObjectHeaderImpl(null, true).equals(header));
+        assertEquals(new ObjectHeaderImpl(null, true), header);
     }
 
     @Test
index 2e7951f4c547462df2f308449a58fab376fde397..e00edae059a3c4ebde6ee0fcfb0abd60a53643ff 100644 (file)
@@ -92,7 +92,7 @@ public class RegistryTest {
 
     public final List<AutoCloseable> regs = new ArrayList<>();
 
-    AbstractPCEPExtensionProviderActivator activator = new AbstractPCEPExtensionProviderActivator() {
+    final AbstractPCEPExtensionProviderActivator activator = new AbstractPCEPExtensionProviderActivator() {
 
         @Override
         protected List<AutoCloseable> startImpl(final PCEPExtensionProviderContext context) {
@@ -100,7 +100,7 @@ public class RegistryTest {
         }
     };
 
-    PCEPExtensionProviderContext ctx = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
+    final PCEPExtensionProviderContext ctx = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
 
     @Before
     public void setUp() throws PCEPDeserializerException {
index 173a696ae1f4fc212a31be944531a2ed6a94f85f..d808111d356d9cad25b77de37ffed749c2a927ee 100644 (file)
@@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SimpleSessionListener implements PCEPSessionListener {
 
-    private List<Message> messages = Lists.newArrayList();
+    private final List<Message> messages = Lists.newArrayList();
 
     private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
 
index dad70f519a65b3bd90057cef808927d41355a21f..e6529e8368e0cce2c96b8f50fb9aa1d211f16109 100755 (executable)
@@ -104,7 +104,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
     private InstanceIdentifier<PathComputationClient> pccIdentifier;
     @GuardedBy("this")
     private TopologyNodeState nodeState;
-    private AtomicBoolean synced = new AtomicBoolean(false);
+    private final AtomicBoolean synced = new AtomicBoolean(false);
     @GuardedBy("this")
     private PCEPSession session;
     @GuardedBy("this")
index 05082474343906596deb6ebd1e0d10d780d18dfb..a8e6a0a9c2762a8d89016b87e6b3d5efffd9d91a 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
@@ -55,7 +56,8 @@ final class OperationResults implements OperationResult {
     public static OperationResults createUnsent(final PCEPErrors error) {
         final List<Errors> e = error != null ? Collections.singletonList(getErrorFor(error))
                 : Collections.emptyList();
-        return new OperationResults(FailureType.Unsent, Lists.transform(e, CONVERT_ERRORS));
+        return new OperationResults(FailureType.Unsent, e.stream().map(CONVERT_ERRORS::apply)
+                .collect(Collectors.toList()));
     }
 
     private static Errors getErrorFor(final PCEPErrors error) {
index 0b92bb0a29259b149da1f7380cdc9ab7310bfcc0..6bb3c519eb5fb80a6b1e92222e6da18de508af9c 100644 (file)
@@ -100,9 +100,9 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
     @GuardedBy("this")
     private final List<PlspId> staleLsps = new ArrayList<>();
 
-    private AtomicBoolean statefulCapability = new AtomicBoolean(false);
-    private AtomicBoolean lspUpdateCapability = new AtomicBoolean(false);
-    private AtomicBoolean initiationCapability = new AtomicBoolean(false);
+    private final AtomicBoolean statefulCapability = new AtomicBoolean(false);
+    private final AtomicBoolean lspUpdateCapability = new AtomicBoolean(false);
+    private final AtomicBoolean initiationCapability = new AtomicBoolean(false);
 
     /**
      * Creates a new stateful topology session listener for given server session manager.
index 85610d80547f01e31aeb238d862713a894dc8dd7..4f98d9ae9220665d4cd39fefdf14d1db968761e3 100644 (file)
@@ -349,7 +349,7 @@ public class ProgrammingServiceImplTest extends AbstractProgrammingTest {
 
         doReturn(dependencies).when(mockedSubmitInstruction).getPreconditions();
         doReturn(new InstructionId(id)).when(mockedSubmitInstruction).getId();
-        doReturn(deadline.isPresent() ? deadline.get() : new Nanotime(BigInteger.valueOf(Long.MAX_VALUE)))
+        doReturn(deadline.orElseGet(() -> new Nanotime(BigInteger.valueOf(Long.MAX_VALUE))))
                 .when(mockedSubmitInstruction).getDeadline();
         return mockedSubmitInstruction;
     }
index 3248dc4f18df5736e92595649f38b53e58420f99..892ed168b82d3cd480a1be80a57ae18f8076042d 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.net.HostAndPort;
 import java.net.InetSocketAddress;
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Created as a util for test tools.
@@ -25,8 +26,8 @@ public final class InetSocketAddressUtil {
     }
 
     public static List<InetSocketAddress> parseAddresses(final String address, final int defaultPort) {
-        return Lists.transform(Arrays.asList(address.split(SEPARATOR)),
-            input -> getInetSocketAddress(input, defaultPort));
+        return Arrays.asList(address.split(SEPARATOR)).stream()
+                .map(input -> getInetSocketAddress(input, defaultPort)).collect(Collectors.toList());
     }
 
     public static List<InetSocketAddress> parseAddresses(final String address) {
index 1f79e91f79333cf2f1e4d70444ed46b60d2e5dcc..0e822e5dc250881de62a6419bf27252e21c9c44d 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.util;
 
 import static junit.framework.TestCase.assertNull;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
@@ -49,7 +49,7 @@ public class CheckUtilTest extends AbstractConcurrentDataBrokerTest {
     private final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIIdKeyed =
             InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
                     new TopologyKey(TOPOLOGY_ID));
-    private static int TIMEOUT = 1;
+    private static final int TIMEOUT = 1;
     @Mock
     private ListenerCheck listenerCheck;
     @Mock
@@ -162,7 +162,7 @@ public class CheckUtilTest extends AbstractConcurrentDataBrokerTest {
 
     @Test(expected = AssertionError.class)
     public void testCheckEquals() throws Exception {
-        checkEquals(() -> assertTrue(false), TIMEOUT);
+        checkEquals(() -> fail(), TIMEOUT);
     }
 
     @Test(expected = AssertionError.class)
index 231b5b76077e9ebe3e18e9636ff3b4af88908603..d5652521d8a6bc3403d56953a904741179dfd5b8 100644 (file)
@@ -135,9 +135,8 @@ public class ByteArrayTest {
         final String FILE_TO_TEST = "src/test/resources/PCEStatefulCapabilityTlv1.bin";
 
         final File fileToCompareWith = new File(FILE_TO_TEST);
-        final InputStream bytesIStream = new FileInputStream(fileToCompareWith);
 
-        try {
+        try (InputStream bytesIStream = new FileInputStream(fileToCompareWith)) {
             final byte[] actualBytes = ByteArray.fileToBytes(FILE_TO_TEST);
 
             if (fileToCompareWith.length() > Integer.MAX_VALUE) {
@@ -154,8 +153,6 @@ public class ByteArrayTest {
             }
 
             assertArrayEquals(expectedBytes, actualBytes);
-        } finally {
-            bytesIStream.close();
         }
     }