From 184ac4d3b25d6f9ec21636ca25f943f81560ba71 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 20 Apr 2023 13:57:05 +0200 Subject: [PATCH] Propagate supported features from ModuleInfoSnapshotResolver ModuleInfoSnapshotResolver should follow the same pattern as Builder to allow users to add supported features -- except it talks to a different backing entity. JIRA: MDSAL-789 Change-Id: I901e188e33e2508e5c20d135fe57399bc3c81f68 Signed-off-by: matus.matok Signed-off-by: Robert Varga --- .../runtime/spi/ModuleInfoSnapshotResolver.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotResolver.java b/binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotResolver.java index 7a9dae3fb7..6eac08fa3d 100644 --- a/binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotResolver.java +++ b/binding/mdsal-binding-runtime-spi/src/main/java/org/opendaylight/mdsal/binding/runtime/spi/ModuleInfoSnapshotResolver.java @@ -13,6 +13,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import com.google.common.collect.MultimapBuilder; import java.io.IOException; @@ -27,12 +28,16 @@ import org.checkerframework.checker.lock.qual.Holding; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.Mutable; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.yang.binding.DataRoot; +import org.opendaylight.yangtools.yang.binding.YangFeature; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.contract.Naming; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement; @@ -92,12 +97,22 @@ public final class ModuleInfoSnapshotResolver implements Mutable { private final ListMultimap sourceToInfoReg = MultimapBuilder.hashKeys().arrayListValues().build(); @GuardedBy("this") + private final ListMultimap, ImmutableSet>> moduleToFeatures = + MultimapBuilder.hashKeys().arrayListValues().build(); + @GuardedBy("this") private @Nullable ModuleInfoSnapshot currentSnapshot; public ModuleInfoSnapshotResolver(final String name, final YangParserFactory parserFactory) { ctxResolver = YangTextSchemaContextResolver.create(name, parserFactory); } + public synchronized Registration registerModuleFeatures(final Class module, + final Set> supportedFeatures) { + final var features = supportedFeatures.stream().map(YangFeature::qname).map(QName::getLocalName).sorted() + .collect(ImmutableSet.toImmutableSet()); + return ctxResolver.registerSupportedFeatures(BindingReflections.getQNameModule(module), features); + } + public synchronized List> registerModuleInfos( final Iterable moduleInfos) { final var ret = new ArrayList>(); -- 2.36.6