diff options
author | 2016-07-13 11:52:51 +0200 | |
---|---|---|
committer | 2016-07-21 14:18:59 +0200 | |
commit | d4b205bc665bebffec8545af5c4992327149c9c3 (patch) | |
tree | 980fd2e803397c6bfa1b4be159a60b59d03b860e /v3po/translate-utils/src/main/java/org/opendaylight | |
parent | 74290324e58983057e0a6e5ae37eb7e6a1646207 (diff) |
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 <mmarsale@cisco.com>
Diffstat (limited to 'v3po/translate-utils/src/main/java/org/opendaylight')
2 files changed, 6 insertions, 63 deletions
diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingReaderRegistryModule.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingReaderRegistryModule.java index fccd6b1c2..e1f04ebe2 100644 --- a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingReaderRegistryModule.java +++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/DelegatingReaderRegistryModule.java @@ -1,18 +1,6 @@ package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import io.fd.honeycomb.v3po.translate.read.ReadContext; -import io.fd.honeycomb.v3po.translate.read.ReadFailedException; -import io.fd.honeycomb.v3po.translate.read.Reader; -import io.fd.honeycomb.v3po.translate.read.ReaderRegistry; -import io.fd.honeycomb.v3po.translate.util.read.DelegatingReaderRegistry; -import java.util.List; -import javax.annotation.Nonnull; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import io.fd.honeycomb.v3po.translate.util.read.registry.CompositeReaderRegistryBuilder; public class DelegatingReaderRegistryModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractDelegatingReaderRegistryModule { public DelegatingReaderRegistryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { @@ -30,53 +18,8 @@ public class DelegatingReaderRegistryModule extends org.opendaylight.yang.gen.v1 @Override public java.lang.AutoCloseable createInstance() { - final List<Reader<? extends DataObject>> rootReadersDependency = Lists.transform(getRootReadersDependency(), - new Function<Reader, Reader<? extends DataObject>>() { - - @SuppressWarnings("unchecked") - @Override - public Reader<? extends DataObject> apply(final Reader input) { - return input; - } - }); - return new CloseableReaderRegistry(new DelegatingReaderRegistry(rootReadersDependency)); - } - - - - // TODO move to translate-utils - private static final class CloseableReaderRegistry implements ReaderRegistry, AutoCloseable { - private final DelegatingReaderRegistry delegatingReaderRegistry; - - CloseableReaderRegistry( - final DelegatingReaderRegistry delegatingReaderRegistry) { - this.delegatingReaderRegistry = delegatingReaderRegistry; - } - - @Override - @Nonnull - public Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> readAll( - @Nonnull final ReadContext ctx) throws ReadFailedException { - return delegatingReaderRegistry.readAll(ctx); - } - - @Nonnull - @Override - public Optional<? extends DataObject> read( - @Nonnull final InstanceIdentifier<? extends DataObject> id, - @Nonnull final ReadContext ctx) throws ReadFailedException { - return delegatingReaderRegistry.read(id, ctx); - } - - @Nonnull - @Override - public InstanceIdentifier<DataObject> getManagedDataObjectType() { - return delegatingReaderRegistry.getManagedDataObjectType(); - } - - @Override - public void close() throws Exception { - // NOOP - } + final CompositeReaderRegistryBuilder flatReaderRegistryBuilder = new CompositeReaderRegistryBuilder(); + getReaderFactoryDependency().forEach(readerFactory -> readerFactory.init(flatReaderRegistryBuilder)); + return flatReaderRegistryBuilder; } } diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java index fedd069f1..0f72df9da 100644 --- a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java +++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/NoopWriterRegistryModule.java @@ -1,8 +1,8 @@ package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406; import io.fd.honeycomb.v3po.translate.util.write.NoopWriterRegistry; -import io.fd.honeycomb.v3po.translate.write.WriterRegistry; -import io.fd.honeycomb.v3po.translate.write.WriterRegistryBuilder; +import io.fd.honeycomb.v3po.translate.write.registry.WriterRegistry; +import io.fd.honeycomb.v3po.translate.write.registry.WriterRegistryBuilder; public class NoopWriterRegistryModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractNoopWriterRegistryModule { public NoopWriterRegistryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { |