From 20e54b17e3b62690135479e269a564e2b1fc6cf0 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 26 Oct 2016 12:19:23 +0200 Subject: Honeycomb-73 Extensible initializers for samples Change-Id: I08f53a301cc147ce1e8cce8b3bd5c82e8f4b21fd Signed-off-by: Maros Marsalek --- .../mapping/oper/InterfaceReaderCustomizer.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'samples/interfaces/mapping/src/main/java/io/fd/honeycomb/samples/interfaces/mapping/oper/InterfaceReaderCustomizer.java') diff --git a/samples/interfaces/mapping/src/main/java/io/fd/honeycomb/samples/interfaces/mapping/oper/InterfaceReaderCustomizer.java b/samples/interfaces/mapping/src/main/java/io/fd/honeycomb/samples/interfaces/mapping/oper/InterfaceReaderCustomizer.java index 7b69005e0..850c1396b 100644 --- a/samples/interfaces/mapping/src/main/java/io/fd/honeycomb/samples/interfaces/mapping/oper/InterfaceReaderCustomizer.java +++ b/samples/interfaces/mapping/src/main/java/io/fd/honeycomb/samples/interfaces/mapping/oper/InterfaceReaderCustomizer.java @@ -19,11 +19,13 @@ package io.fd.honeycomb.samples.interfaces.mapping.oper; import io.fd.honeycomb.samples.interfaces.mapping.LowerLayerAccess; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; import java.util.List; import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.InterfaceId; +import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.Interfaces; import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.InterfacesStateBuilder; import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.state.InterfaceBuilder; @@ -37,7 +39,8 @@ import org.slf4j.LoggerFactory; /** * This is a customizer responsible for reading Interface operational data */ -public class InterfaceReaderCustomizer implements ListReaderCustomizer { +public class InterfaceReaderCustomizer implements + InitializingListReaderCustomizer { private static final Logger LOG = LoggerFactory.getLogger(InterfaceReaderCustomizer.class); private final LowerLayerAccess access; @@ -100,4 +103,18 @@ public class InterfaceReaderCustomizer implements ListReaderCustomizer init( + @Nonnull final InstanceIdentifier id, + @Nonnull final Interface readValue, + @Nonnull final ReadContext ctx) { + return Initialized.create(InstanceIdentifier.create(Interfaces.class) + .child(org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.Interface.class, + new org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.InterfaceKey( + id.firstKeyOf(Interface.class).getInterfaceId())), + new org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.InterfaceBuilder() + .setMtu(readValue.getMtu()) + .setInterfaceId(readValue.getInterfaceId()) + .build()); + } } -- cgit 1.2.3-korg