BUG-3823 : fixed sonar issues in BGP 82/24282/3
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 20 Jul 2015 11:42:21 +0000 (13:42 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 20 Jul 2015 14:57:52 +0000 (14:57 +0000)
Mostly reduced method complexity.

Change-Id: Ib3bb6a6cc95b854afb61534dc35a45652fc2d2c8
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
bgp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpRouterPeerImpl.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPErrorIdentifier.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPUpdateMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/WithdrawnRoutesSerializer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSynchronization.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BestPathSelector.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.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/UriBuilder.java

index 7f12befcc9aee550cce611cbd991a0879bf7d120..b9b7008023a6dc0ee29f53b12959fdf33ab3f8a4 100644 (file)
@@ -262,39 +262,43 @@ public final class BmpRouterPeerImpl implements BmpRouterPeer {
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder =
                 Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Stats.QNAME));
         builder.withChild(ImmutableNodes.leafNode(PEER_STATS_TIMESTAMP_QNAME, timestamp.getValue()));
-        if (stat.getTlvs() != null) {
-            final Tlvs tlvs = stat.getTlvs();
-            if (tlvs.getRejectedPrefixesTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT0_QNAME, tlvs.getRejectedPrefixesTlv().getCount().getValue()));
-            }
-            if (tlvs.getDuplicatePrefixAdvertisementsTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT1_QNAME, tlvs.getDuplicatePrefixAdvertisementsTlv().getCount().getValue()));
-            }
-            if (tlvs.getDuplicateWithdrawsTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT2_QNAME, tlvs.getDuplicateWithdrawsTlv().getCount().getValue()));
-            }
-            if (tlvs.getInvalidatedClusterListLoopTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT3_QNAME, tlvs.getInvalidatedClusterListLoopTlv().getCount().getValue()));
-            }
-            if (tlvs.getInvalidatedAsPathLoopTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT4_QNAME, tlvs.getInvalidatedAsPathLoopTlv().getCount().getValue()));
-            }
-            if (tlvs.getInvalidatedOriginatorIdTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT5_QNAME, tlvs.getInvalidatedOriginatorIdTlv().getCount().getValue()));
-            }
-            if (tlvs.getInvalidatedAsConfedLoopTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT6_QNAME, tlvs.getInvalidatedAsConfedLoopTlv().getCount().getValue()));
-            }
-            if (tlvs.getAdjRibsInRoutesTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT7_QNAME, tlvs.getAdjRibsInRoutesTlv().getCount().getValue()));
-            }
-            if (tlvs.getLocRibRoutesTlv() != null) {
-                builder.withChild(ImmutableNodes.leafNode(STAT8_QNAME, tlvs.getLocRibRoutesTlv().getCount().getValue()));
-            }
+        final Tlvs tlvs = stat.getTlvs();
+        if (tlvs != null) {
+            statsForTlvs(tlvs, builder);
         }
         return builder.build();
     }
 
+    private static void statsForTlvs(final Tlvs tlvs, final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder) {
+        if (tlvs.getRejectedPrefixesTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT0_QNAME, tlvs.getRejectedPrefixesTlv().getCount().getValue()));
+        }
+        if (tlvs.getDuplicatePrefixAdvertisementsTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT1_QNAME, tlvs.getDuplicatePrefixAdvertisementsTlv().getCount().getValue()));
+        }
+        if (tlvs.getDuplicateWithdrawsTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT2_QNAME, tlvs.getDuplicateWithdrawsTlv().getCount().getValue()));
+        }
+        if (tlvs.getInvalidatedClusterListLoopTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT3_QNAME, tlvs.getInvalidatedClusterListLoopTlv().getCount().getValue()));
+        }
+        if (tlvs.getInvalidatedAsPathLoopTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT4_QNAME, tlvs.getInvalidatedAsPathLoopTlv().getCount().getValue()));
+        }
+        if (tlvs.getInvalidatedOriginatorIdTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT5_QNAME, tlvs.getInvalidatedOriginatorIdTlv().getCount().getValue()));
+        }
+        if (tlvs.getInvalidatedAsConfedLoopTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT6_QNAME, tlvs.getInvalidatedAsConfedLoopTlv().getCount().getValue()));
+        }
+        if (tlvs.getAdjRibsInRoutesTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT7_QNAME, tlvs.getAdjRibsInRoutesTlv().getCount().getValue()));
+        }
+        if (tlvs.getLocRibRoutesTlv() != null) {
+            builder.withChild(ImmutableNodes.leafNode(STAT8_QNAME, tlvs.getLocRibRoutesTlv().getCount().getValue()));
+        }
+    }
+
     private static String getStringIpAddress(final IpAddress ipAddress) {
         if (ipAddress.getIpv4Address() != null) {
             return ipAddress.getIpv4Address().getValue();
index bcaa35242e72e7303a396c33ddcb524aa041c0d3..6ff2173038d7d756f4032b97f4d681e15fb333f3 100644 (file)
@@ -44,17 +44,11 @@ final class BGPErrorIdentifier implements Serializable {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (this.getClass() != obj.getClass()) {
+        if (obj == null || this.getClass() != obj.getClass()) {
             return false;
         }
         final BGPErrorIdentifier other = (BGPErrorIdentifier) obj;
-        if (this.code != other.code) {
-            return false;
-        }
-        if (this.subcode != other.subcode) {
+        if (this.code != other.code || this.subcode != other.subcode) {
             return false;
         }
         return true;
index 582f7acd106936f2660f8eb3c473ce229a9c6079..1c39deaf0e1ec64a871a4130fb2d3aae2021d2b4 100644 (file)
@@ -81,7 +81,7 @@ public final class BGPUpdateMessageParser implements MessageParser, MessageSeria
             }
         }
         final List<Ipv4Prefix> nlri = Ipv4Util.prefixListForBytes(ByteArray.readAllBytes(buffer));
-        if (nlri != null && !nlri.isEmpty()) {
+        if (!nlri.isEmpty()) {
             builder.setNlri(new NlriBuilder().setNlri(nlri).build());
         }
         final Update msg = builder.build();
index d3f6f1949e830fbd0cbb3bcee14bf595494145b1..abd8700481f69a0e6d2426a53eb98dcc3697eeaa 100644 (file)
@@ -37,19 +37,23 @@ public class WithdrawnRoutesSerializer implements NlriSerializer {
         }
         final WithdrawnRoutes routes = mpUnreachNlri.getWithdrawnRoutes();
         if (routes != null) {
-            if (routes.getDestinationType() instanceof DestinationIpv4Case) {
-                final DestinationIpv4Case destinationIpv4Case = (DestinationIpv4Case)routes.getDestinationType();
-                if (destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes() != null) {
-                    for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
-                        byteAggregator.writeBytes(Ipv4Util.bytesForPrefixBegin(ipv4Prefix.getPrefix()));
-                    }
+            serializeRoutes(routes, byteAggregator);
+        }
+    }
+
+    private static void serializeRoutes(final WithdrawnRoutes routes, final ByteBuf byteAggregator) {
+        if (routes.getDestinationType() instanceof DestinationIpv4Case) {
+            final DestinationIpv4Case destinationIpv4Case = (DestinationIpv4Case) routes.getDestinationType();
+            if (destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes() != null) {
+                for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
+                    byteAggregator.writeBytes(Ipv4Util.bytesForPrefixBegin(ipv4Prefix.getPrefix()));
                 }
-            } else if (routes.getDestinationType() instanceof DestinationIpv6Case) {
-                final  DestinationIpv6Case destinationIpv6Case = (DestinationIpv6Case) routes.getDestinationType();
-                if (destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes() != null) {
-                    for (final Ipv6Prefixes ipv6Prefix : destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes()) {
-                        byteAggregator.writeBytes(Ipv6Util.bytesForPrefixBegin(ipv6Prefix.getPrefix()));
-                    }
+            }
+        } else if (routes.getDestinationType() instanceof DestinationIpv6Case) {
+            final DestinationIpv6Case destinationIpv6Case = (DestinationIpv6Case) routes.getDestinationType();
+            if (destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes() != null) {
+                for (final Ipv6Prefixes ipv6Prefix : destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes()) {
+                    byteAggregator.writeBytes(Ipv6Util.bytesForPrefixBegin(ipv6Prefix.getPrefix()));
                 }
             }
         }
index 1ea1f62a1c02708e2bc2cd0de14327a0e37b0e0f..a7313ee941c1c3da63c26a65a67b779fe4d06543 100644 (file)
@@ -81,10 +81,10 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
 
         final Bootstrap b = new Bootstrap();
         final BGPProtocolSessionPromise p = new BGPProtocolSessionPromise(this.executor, address, strategy, b);
-        b.option(ChannelOption.SO_KEEPALIVE, Boolean.valueOf(true));
+        b.option(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
         b.handler(BGPChannel.createChannelInitializer(initializer, p));
         this.customizeBootstrap(b);
-        this.setWorkerGroup(b);
+        setWorkerGroup(b);
         p.connect();
         LOG.debug("Client created.");
         return p;
@@ -109,9 +109,9 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         final Bootstrap b = new Bootstrap();
         final BGPReconnectPromise p = new BGPReconnectPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE, address,
             connectStrategyFactory, b, BGPChannel.createChannelPipelineInitializer(BGPDispatcherImpl.this.hf.getDecoders(), snf, BGPDispatcherImpl.this.hf.getEncoders()));
-        b.option(ChannelOption.SO_KEEPALIVE, Boolean.valueOf(true));
+        b.option(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
         this.customizeBootstrap(b);
-        this.setWorkerGroup(b);
+        setWorkerGroup(b);
         p.connect();
 
         this.keys = null;
@@ -166,7 +166,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
 
         try {
             b.channel(NioServerSocketChannel.class);
-        } catch (IllegalStateException e) {
+        } catch (final IllegalStateException e) {
             LOG.trace("Not overriding channelFactory on bootstrap {}", b, e);
         }
     }
@@ -177,7 +177,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         }
         try {
             b.channel(NioSocketChannel.class);
-        } catch (IllegalStateException e) {
+        } catch (final IllegalStateException e) {
             LOG.trace("Not overriding channelFactory on bootstrap {}", b, e);
         }
     }
@@ -204,7 +204,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         public static <S extends BGPSession> ChannelHandler createChannelInitializer(final ChannelPipelineInitializer initializer, final Promise<S> promise) {
             return new ChannelInitializer<SocketChannel>() {
                 @Override
-                protected void initChannel(SocketChannel ch) {
+                protected void initChannel(final SocketChannel ch) {
                     initializer.initializeChannel(ch, promise);
                 }
             };
index 8c311942fc265371417dc390911cda8e4c91f89a..279b91dbc68d24e81e6bc32e00a51c2b138926e5 100644 (file)
@@ -101,6 +101,10 @@ public class BGPSynchronization {
                 isEOR = true;
             }
         }
+        syncType(type, isEOR);
+    }
+
+    private void syncType(final TablesKey type, final boolean isEOR) {
         final SyncVariables s = this.syncStorage.get(type);
         if (s == null) {
             LOG.warn("BGPTableType was not present in open message : {}", type);
index 25ee8a58ba424bd27f4466c41dc44e800a8327e2..83be8cb31488ee4af3621e680e86daedc5b746c3 100644 (file)
@@ -60,7 +60,7 @@ final class BestPathSelector {
              * are better.
              */
             final BestPathState state = new BestPathState(attrs);
-            if (this.bestOriginatorId == null || !isExistingPathBetter(originatorId, state)) {
+            if (this.bestOriginatorId == null || !isExistingPathBetter(state)) {
                 LOG.trace("Selecting path from router {}", routerId);
                 this.bestOriginatorId = originatorId;
                 this.bestRouterId = routerId;
@@ -76,14 +76,12 @@ final class BestPathSelector {
     /**
      * Chooses best route according to BGP best path selection.
      *
-     * @param originatorId of the new route
      * @param state attributes of the new route
      * @return true if the existing path is better, false if the new path is better
      */
-    private boolean isExistingPathBetter(@Nonnull final UnsignedInteger originatorId, @Nonnull final BestPathState state) {
+    private boolean isExistingPathBetter(@Nonnull final BestPathState state) {
         // 1. prefer path with accessible nexthop
         // - we assume that all nexthops are accessible
-
         /*
          * 2. prefer path with higher LOCAL_PREF
          *
@@ -102,7 +100,6 @@ final class BestPathSelector {
         if (state.getLocalPref() != null && state.getLocalPref() < this.bestState.getLocalPref()) {
             return true;
         }
-
         // 3. prefer learned path
         // - we assume that all paths are learned
 
@@ -120,7 +117,6 @@ final class BestPathSelector {
             // This trick relies on the order in which the values are declared in the model.
             return no.ordinal() > bo.ordinal();
         }
-
         // FIXME: we should be able to cache the best AS
         final Long bestAs = this.bestState.getPeerAs();
         final Long newAs = state.getPeerAs();
index 8c7d4b3b8483ad356958093b206a1b65e2407f34..f1445128120fa398c6ee2572f37c4de7683ee2af 100644 (file)
@@ -53,6 +53,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.Peer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
 import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeFactory;
 import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
@@ -148,7 +149,7 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
 
         final DOMDataBrokerExtension domDatatreeChangeService = this.domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
         this.service = domDatatreeChangeService;
-        this.efWriter = EffectiveRibInWriter.create(getService(), this.createPeerChain(this), getYangRibId(), pd, this.ribContextRegistry);
+        this.efWriter = EffectiveRibInWriter.create(getService(), createPeerChain(this), getYangRibId(), pd, this.ribContextRegistry);
         LOG.debug("Effective RIB created.");
 
         for (final BgpTableType t : this.localTables) {
@@ -183,7 +184,7 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
         } catch (final TransactionCommitFailedException e1) {
             LOG.error("Failed to initiate LocRIB for key {}", key, e1);
         }
-        this.locRibs.add(LocRibWriter.create(this.ribContextRegistry, key, this.createPeerChain(this), getYangRibId(), this.localAs, getService(), pd));
+        this.locRibs.add(LocRibWriter.create(this.ribContextRegistry, key, createPeerChain(this), getYangRibId(), this.localAs, getService(), pd));
     }
 
     @Override
@@ -258,17 +259,7 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
                     getInstanceIdentifier().child(LocRib.class).child(Tables.class, key)).checkedGet();
             if (tableMaybe.isPresent()) {
                 final Tables table = tableMaybe.get();
-                if (table.getRoutes() instanceof Ipv4RoutesCase) {
-                    final Ipv4RoutesCase routesCase = (Ipv4RoutesCase) table.getRoutes();
-                    if (routesCase.getIpv4Routes() != null && routesCase.getIpv4Routes().getIpv4Route() != null) {
-                        return routesCase.getIpv4Routes().getIpv4Route().size();
-                    }
-                } else if (table.getRoutes() instanceof Ipv6RoutesCase) {
-                    final Ipv6RoutesCase routesCase = (Ipv6RoutesCase) table.getRoutes();
-                    if (routesCase.getIpv6Routes() != null && routesCase.getIpv6Routes().getIpv6Route() != null) {
-                        return routesCase.getIpv6Routes().getIpv6Route().size();
-                    }
-                }
+                return countIpRoutes(table.getRoutes());
             }
         } catch (final ReadFailedException e) {
             LOG.debug("Failed to read tables", e);
@@ -276,6 +267,21 @@ public final class RIBImpl extends DefaultRibReference implements AutoCloseable,
         return 0;
     }
 
+    private int countIpRoutes(final Routes routes) {
+        if (routes instanceof Ipv4RoutesCase) {
+            final Ipv4RoutesCase routesCase = (Ipv4RoutesCase) routes;
+            if (routesCase.getIpv4Routes() != null && routesCase.getIpv4Routes().getIpv4Route() != null) {
+                return routesCase.getIpv4Routes().getIpv4Route().size();
+            }
+        } else if (routes instanceof Ipv6RoutesCase) {
+            final Ipv6RoutesCase routesCase = (Ipv6RoutesCase) routes;
+            if (routesCase.getIpv6Routes() != null && routesCase.getIpv6Routes().getIpv6Route() != null) {
+                return routesCase.getIpv6Routes().getIpv6Route().size();
+            }
+        }
+        return 0;
+    }
+
     public Set<TablesKey> getLocalTablesKeys() {
         return this.localTablesKeys;
     }
index 797eee5b86171aa0ff6b5062c06dd35877907697..8424c7733c65b7b4b568674106e55a05ce4c3a33 100644 (file)
@@ -86,12 +86,6 @@ public abstract class AbstractTopologyBuilder<T extends Route> implements AutoCl
         });
     }
 
-    @Deprecated
-    protected AbstractTopologyBuilder(final DataBroker dataProvider, final RibReference locRibReference,
-            final TopologyId topologyId, final TopologyTypes types, final Class<T> idClass) {
-        this(dataProvider, locRibReference, topologyId, types);
-    }
-
     @Deprecated
     public final InstanceIdentifier<Tables> tableInstanceIdentifier(final Class<? extends AddressFamily> afi,
             final Class<? extends SubsequentAddressFamily> safi) {
@@ -133,34 +127,17 @@ public abstract class AbstractTopologyBuilder<T extends Route> implements AutoCl
             LOG.trace("Transaction chain was already closed, skipping update.");
             return;
         }
-
         final ReadWriteTransaction trans = this.chain.newReadWriteTransaction();
         LOG.debug("Received data change {} event with transaction {}", changes, trans.getIdentifier());
-
         for (final DataTreeModification<T> change : changes) {
             try {
-                final DataObjectModification<T> root = change.getRootNode();
-                switch (root.getModificationType()) {
-                case DELETE:
-                    removeObject(trans, change.getRootPath().getRootIdentifier(), root.getDataBefore());
-                    break;
-                case SUBTREE_MODIFIED:
-                case WRITE:
-                    if (root.getDataBefore() != null) {
-                        removeObject(trans, change.getRootPath().getRootIdentifier(), root.getDataBefore());
-                    }
-                    createObject(trans, change.getRootPath().getRootIdentifier(), root.getDataAfter());
-                    break;
-                default:
-                    throw new IllegalArgumentException("Unhandled modification type " + root.getModificationType());
-                }
+                routeChanged(change, trans);
             } catch (final RuntimeException e) {
                 LOG.warn("Data change {} was not completely propagated to listener {}, aborting", change, this, e);
                 trans.cancel();
                 return;
             }
         }
-
         Futures.addCallback(trans.submit(), new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
@@ -174,6 +151,24 @@ public abstract class AbstractTopologyBuilder<T extends Route> implements AutoCl
         });
     }
 
+    private void routeChanged(final DataTreeModification<T> change, final ReadWriteTransaction trans) {
+        final DataObjectModification<T> root = change.getRootNode();
+        switch (root.getModificationType()) {
+        case DELETE:
+            removeObject(trans, change.getRootPath().getRootIdentifier(), root.getDataBefore());
+            break;
+        case SUBTREE_MODIFIED:
+        case WRITE:
+            if (root.getDataBefore() != null) {
+                removeObject(trans, change.getRootPath().getRootIdentifier(), root.getDataBefore());
+            }
+            createObject(trans, change.getRootPath().getRootIdentifier(), root.getDataAfter());
+            break;
+        default:
+            throw new IllegalArgumentException("Unhandled modification type " + root.getModificationType());
+        }
+    }
+
     @Override
     public final void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction, final Throwable cause) {
         // TODO: restart?
index cee04856f739450e609a2d4947a25a9ca5499108..bfa7baf30887f92d103d5634305d90cc6ecca24a 100644 (file)
@@ -102,22 +102,22 @@ final class UriBuilder {
         if (routerIdentifier == null) {
             return null;
         }
-
         if (routerIdentifier instanceof IsisNodeCase) {
             return isoId(((IsisNodeCase) routerIdentifier).getIsisNode().getIsoSystemId());
-        } else if (routerIdentifier instanceof IsisPseudonodeCase) {
+        }
+        if (routerIdentifier instanceof IsisPseudonodeCase) {
             final IsisPseudonode r = ((IsisPseudonodeCase) routerIdentifier).getIsisPseudonode();
-            return isoId(r.getIsIsRouterIdentifier().getIsoSystemId().getValue()) + '.'
-                + Hex.encodeHexString(new byte[] { UnsignedBytes.checkedCast(r.getPsn()) });
-        } else if (routerIdentifier instanceof OspfNodeCase) {
+            return isoId(r.getIsIsRouterIdentifier().getIsoSystemId().getValue()) + '.' + Hex.encodeHexString(new byte[] { UnsignedBytes.checkedCast(r.getPsn()) });
+        }
+        if (routerIdentifier instanceof OspfNodeCase) {
             return ((OspfNodeCase) routerIdentifier).getOspfNode().getOspfRouterId().toString();
-        } else if (routerIdentifier instanceof OspfPseudonodeCase) {
+        }
+        if (routerIdentifier instanceof OspfPseudonodeCase) {
             final OspfPseudonode r = ((OspfPseudonodeCase) routerIdentifier).getOspfPseudonode();
             return r.getOspfRouterId().toString() + ':' + r.getLanInterface().getValue();
-        } else {
-            LOG.warn("Unhandled router identifier type {}, fallback to toString()", routerIdentifier.getImplementedInterface());
-            return routerIdentifier.toString();
         }
+        LOG.warn("Unhandled router identifier type {}, fallback to toString()", routerIdentifier.getImplementedInterface());
+        return routerIdentifier.toString();
     }
 
     UriBuilder add(final String prefix, final NodeIdentifier node) {