From 4e6b846c342b2c9e9443e3d3472685e5acb32fa3 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 13 Jul 2016 11:52:51 +0200 Subject: HONEYCOMB-122 Update reader registry to share similar APIs as writer + Extract common registry builder base code (Reader registry is not flat, so there is not full control over ordering as with writers but it is sufficient) + Split CompositeReader into CompositeReader, SubtreeReader and GenericReader + No need to build composite structure in ReaderFactories (registry does that internally) + Keep only ReaderCustomizer + ListReaderCustomizer, no root reader (same for writers) Change-Id: Ic4e5bc96ad47a6cbcada4efcc2209db5c16d2a6c Signed-off-by: Maros Marsalek --- .../honeycomb/v3po/translate/read/ListReader.java | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java') diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java index faf6f0a19..13a7a55da 100644 --- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java +++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/read/ListReader.java @@ -17,23 +17,26 @@ package io.fd.honeycomb.v3po.translate.read; import com.google.common.annotations.Beta; +import java.util.Collections; import java.util.List; import javax.annotation.Nonnull; +import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * List reader, allowing read of all the elements + * List reader, allowing read of all the elements. * * @param Specific DataObject derived type, that is handled by this reader */ @Beta -public interface ListReader, K extends Identifier> extends Reader { +public interface ListReader + , K extends Identifier, B extends Builder> extends Reader { /** - * Read all elements in this list + * Read all elements in this list. * * @param id Wildcarded identifier of list managed by this reader * @param ctx Read context @@ -42,6 +45,22 @@ public interface ListReader, K extends Id * @throws ReadFailedException if read was unsuccessful */ @Nonnull - List readList(@Nonnull final InstanceIdentifier id, - @Nonnull final ReadContext ctx) throws ReadFailedException; + List readList(@Nonnull final InstanceIdentifier id, @Nonnull final ReadContext ctx) + throws ReadFailedException; + + /** + * Get IDs for all entries in the list. + */ + List getAllIds(@Nonnull InstanceIdentifier id, @Nonnull ReadContext ctx) + throws ReadFailedException; + + /** + * Merge read data into provided parent builder. + */ + void merge(@Nonnull final Builder builder, @Nonnull final List readData); + + @Override + default void merge(@Nonnull final Builder parentBuilder, @Nonnull final D readValue) { + merge(parentBuilder, Collections.singletonList(readValue)); + } } -- cgit 1.2.3-korg