From 275c993b75fb54aa3c764efb74218af245503d78 Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Sat, 21 Apr 2018 23:09:45 +0200 Subject: [PATCH] Remove duplicated code by implementing default behaviour under interface. Change-Id: Ida088bc8d78df7d5cc4bb04fe94fb7946b50073b Signed-off-by: Claudio D. Gasparini --- .../protocol/bgp/evpn/impl/EvpnRibSupport.java | 18 ------------------ .../flowspec/AbstractFlowspecRIBSupport.java | 17 ----------------- .../bgp/inet/AbstractIPRibSupport.java | 10 ---------- .../bgp/l3vpn/AbstractVpnRIBSupport.java | 17 ----------------- .../AbstractLabeledUnicastRIBSupport.java | 17 ----------------- .../linkstate/impl/LinkstateRIBSupport.java | 17 ----------------- .../protocol/bgp/rib/spi/RIBSupport.java | 13 ++++++++++--- .../routes/ipv4/routes/RIBSupportTestImp.java | 15 --------------- 8 files changed, 10 insertions(+), 114 deletions(-) diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java index 06ba62084b..26bdc96352 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.protocol.bgp.evpn.impl; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.Collection; @@ -38,7 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; @@ -67,21 +64,6 @@ final class EvpnRibSupport extends AbstractRIBSupport { return SINGLETON; } - @Override - public ImmutableCollection> cacheableAttributeObjects() { - return ImmutableSet.of(); - } - - @Override - public ImmutableCollection> cacheableNlriObjects() { - return ImmutableSet.of(); - } - - @Override - public boolean isComplexRoute() { - return true; - } - @Override protected DestinationType buildDestination(final Collection routes) { return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.update diff --git a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecRIBSupport.java b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecRIBSupport.java index 9cff3cf881..ed1cb6eecb 100644 --- a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecRIBSupport.java +++ b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecRIBSupport.java @@ -10,8 +10,6 @@ package org.opendaylight.protocol.bgp.flowspec; import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import java.util.Collection; import java.util.Optional; @@ -53,21 +51,6 @@ public abstract class AbstractFlowspecRIBSupport> cacheableAttributeObjects() { - return ImmutableSet.of(); - } - - @Override - public final ImmutableCollection> cacheableNlriObjects() { - return ImmutableSet.of(); - } - - @Override - public final boolean isComplexRoute() { - return true; - } - @Override protected DestinationType buildDestination(final Collection routes) { final MapEntryNode routesCont = Iterables.getOnlyElement(routes); diff --git a/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/AbstractIPRibSupport.java b/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/AbstractIPRibSupport.java index 91691d2522..d39c6727c9 100644 --- a/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/AbstractIPRibSupport.java +++ b/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/AbstractIPRibSupport.java @@ -58,21 +58,11 @@ abstract class AbstractIPRibSupport return this.prefixNid; } - @Override - public final ImmutableCollection> cacheableAttributeObjects() { - return ImmutableSet.of(); - } - @Override public final ImmutableCollection> cacheableNlriObjects() { return this.cacheableNlriObjects; } - @Override - public final boolean isComplexRoute() { - return true; - } - @Override protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) { diff --git a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/AbstractVpnRIBSupport.java b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/AbstractVpnRIBSupport.java index 8b8c96e051..47cdd59dfe 100644 --- a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/AbstractVpnRIBSupport.java +++ b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/AbstractVpnRIBSupport.java @@ -8,8 +8,6 @@ package org.opendaylight.protocol.bgp.l3vpn; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.Collection; @@ -127,21 +125,6 @@ public abstract class AbstractVpnRIBSupport extends AbstractRIBSupport> cacheableAttributeObjects() { - return ImmutableSet.of(); - } - - @Override - public ImmutableCollection> cacheableNlriObjects() { - return ImmutableSet.of(); - } - - @Override - public boolean isComplexRoute() { - return true; - } - @Override protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) { diff --git a/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/AbstractLabeledUnicastRIBSupport.java b/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/AbstractLabeledUnicastRIBSupport.java index 8d575bb0f5..2e3b56f11f 100644 --- a/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/AbstractLabeledUnicastRIBSupport.java +++ b/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/AbstractLabeledUnicastRIBSupport.java @@ -8,8 +8,6 @@ package org.opendaylight.protocol.bgp.labeled.unicast; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.ArrayList; @@ -84,21 +82,6 @@ abstract class AbstractLabeledUnicastRIBSupport super(cazeClass, containerClass, listClass, addressFamilyClass, safiClass, destinationQname); } - @Override - public ImmutableCollection> cacheableAttributeObjects() { - return ImmutableSet.of(); - } - - @Override - public ImmutableCollection> cacheableNlriObjects() { - return ImmutableSet.of(); - } - - @Override - public boolean isComplexRoute() { - return true; - } - @Override protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) { diff --git a/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/LinkstateRIBSupport.java b/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/LinkstateRIBSupport.java index 7334245112..f5a59e86e9 100644 --- a/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/LinkstateRIBSupport.java +++ b/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/LinkstateRIBSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.protocol.bgp.linkstate.impl; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.Arrays; @@ -83,21 +81,6 @@ public final class LinkstateRIBSupport extends AbstractRIBSupport> cacheableAttributeObjects() { - return ImmutableSet.of(); - } - - @Override - public ImmutableCollection> cacheableNlriObjects() { - return ImmutableSet.of(); - } - - @Override - public boolean isComplexRoute() { - return true; - } - @Override protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) { diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java index 29a63a5f00..b0b0cd73a0 100644 --- a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java +++ b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java @@ -8,6 +8,7 @@ package org.opendaylight.protocol.bgp.rib.spi; import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableSet; import java.util.Collection; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -84,10 +85,14 @@ public interface RIBSupport extends AddPa Class routesListClass(); @Nonnull - ImmutableCollection> cacheableAttributeObjects(); + default ImmutableCollection> cacheableAttributeObjects() { + return ImmutableSet.of(); + } @Nonnull - ImmutableCollection> cacheableNlriObjects(); + default ImmutableCollection> cacheableNlriObjects() { + return ImmutableSet.of(); + } /** * Given the NLRI as ContainerNode, this method should extract withdrawn routes @@ -176,7 +181,9 @@ public interface RIBSupport extends AddPa * @deprecated All routes are complex. */ @Deprecated - boolean isComplexRoute(); + default boolean isComplexRoute() { + return true; + } /** * To send routes out, we'd need to transform the DOM representation of route to diff --git a/bgp/rib-spi/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/bgp/inet/rev150305/ipv4/routes/ipv4/routes/RIBSupportTestImp.java b/bgp/rib-spi/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/bgp/inet/rev150305/ipv4/routes/ipv4/routes/RIBSupportTestImp.java index f72a8524d4..4481026674 100644 --- a/bgp/rib-spi/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/bgp/inet/rev150305/ipv4/routes/ipv4/routes/RIBSupportTestImp.java +++ b/bgp/rib-spi/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/bgp/inet/rev150305/ipv4/routes/ipv4/routes/RIBSupportTestImp.java @@ -62,21 +62,6 @@ public final class RIBSupportTestImp extends AbstractRIBSupport { .bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route.QNAME), PREFIX_NII, destination, attributes); } - @Override - public ImmutableCollection> cacheableAttributeObjects() { - return null; - } - - @Override - public ImmutableCollection> cacheableNlriObjects() { - return null; - } - - @Override - public boolean isComplexRoute() { - return false; - } - @Override public Route createRoute(final Route route, final String routeKey, final long pathId, final Attributes attributes) { return null; -- 2.36.6