From 3afa4e3d471e2c6178c4f8a5600003a53288b34f Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Tue, 8 Nov 2016 12:34:36 +0100 Subject: HONEYCOMB-270 Remove read (presence) workarounds for nat Change-Id: Ia0986dbe173123a4dca4f7f3bf65e7ba4851b1b7 Signed-off-by: Maros Marsalek --- .../read/ifc/InterfaceInboundNatCustomizer.java | 60 +++------------------- 1 file changed, 6 insertions(+), 54 deletions(-) (limited to 'nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ifc/InterfaceInboundNatCustomizer.java') diff --git a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ifc/InterfaceInboundNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ifc/InterfaceInboundNatCustomizer.java index 52467a19a..3e4b60fb4 100644 --- a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ifc/InterfaceInboundNatCustomizer.java +++ b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ifc/InterfaceInboundNatCustomizer.java @@ -17,6 +17,7 @@ package io.fd.honeycomb.nat.read.ifc; import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.Initialized; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.vpp.util.NamingContext; @@ -32,8 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interfa import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev161214._interface.nat.attributes.nat.Inbound; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.nat.rev161214._interface.nat.attributes.nat.InboundBuilder; import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -55,8 +54,10 @@ final class InterfaceInboundNatCustomizer extends AbstractInterfaceNatCustomizer } @Override - void setBuilderPresence(@Nonnull final InboundBuilder builder) { - ((PresenceInboundBuilder) builder).setPresent(true); + public void readCurrentAttributes(@Nonnull final InstanceIdentifier id, + @Nonnull final InboundBuilder builder, @Nonnull final ReadContext ctx) + throws ReadFailedException { + super.readCurrentAttributes(id, builder, ctx); } @Override @@ -68,7 +69,7 @@ final class InterfaceInboundNatCustomizer extends AbstractInterfaceNatCustomizer @Override public InboundBuilder getBuilder(@Nonnull final InstanceIdentifier id) { // Return not present value by default - return new PresenceInboundBuilder(false); + return new InboundBuilder(); } @Override @@ -91,53 +92,4 @@ final class InterfaceInboundNatCustomizer extends AbstractInterfaceNatCustomizer .child(Inbound.class); return Initialized.create(cfgId, readValue); } - - // TODO HONEYCOMB-270, make this better, having to fake a builder + value is just exploitation. - - /** - * Special Builder to also propagate empty container into the resulting data. - */ - private static final class PresenceInboundBuilder extends InboundBuilder { - - private volatile boolean isPresent = false; - - PresenceInboundBuilder(final boolean isPresent) { - this.isPresent = isPresent; - } - - void setPresent(final boolean present) { - this.isPresent = present; - } - - @Override - public Inbound build() { - return isPresent - ? super.build() - : NotPresentInbound.NOT_PRESENT_INBOUND; - } - } - - /** - * Fake container that returns false on equals. - */ - private static final class NotPresentInbound implements Inbound { - - private static final NotPresentInbound NOT_PRESENT_INBOUND = new NotPresentInbound(); - - @Override - public > E getAugmentation(final Class augmentationType) { - throw new UnsupportedOperationException(); - } - - @Override - public Class getImplementedInterface() { - return Inbound.class; - } - - @Override - public boolean equals(final Object obj) { - // This is necessary to fake this.equals(something) - return obj == NOT_PRESENT_INBOUND; - } - } } -- cgit 1.2.3-korg