</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-repo-spi</artifactId>
+ <artifactId>yang-repo-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
requires transitive org.opendaylight.yangtools.concepts;
requires transitive org.opendaylight.yangtools.yang.common;
requires transitive org.opendaylight.yangtools.yang.model.api;
+ requires transitive org.opendaylight.yangtools.yang.repo.api;
requires transitive org.opendaylight.yangtools.yang.binding;
- requires transitive org.opendaylight.yangtools.yang.repo.spi;
requires transitive org.opendaylight.yangtools.rfc8040.model.api;
requires transitive org.opendaylight.mdsal.binding.model.api;
requires org.slf4j;
package org.opendaylight.mdsal.binding.runtime.api;
import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
+import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
/**
* A snapshot of a set of {@link YangModuleInfo}s, assembled to form an {@link EffectiveModelContext}.
*/
@Beta
-public interface ModuleInfoSnapshot extends Immutable, SchemaSourceProvider<YangTextSource> {
+@NonNullByDefault
+public interface ModuleInfoSnapshot extends Immutable {
/**
* The {@link EffectiveModelContext} resulting from all models exposed from constituent module infos.
*
* @return the resulting model context
*/
- @NonNull EffectiveModelContext modelContext();
+ EffectiveModelContext modelContext();
+
+ @Nullable YangTextSource yangTextSource(SourceIdentifier sourceId);
+
+ YangTextSource getYangTextSource(SourceIdentifier sourceId) throws MissingSchemaSourceException;
<T> Class<T> loadClass(String fullyQualifiedName) throws ClassNotFoundException;
}
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
}
@Override
- public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceId) {
+ public YangTextSource yangTextSource(final SourceIdentifier sourceId) {
final var info = moduleInfos.get(sourceId);
- return info == null
- ? Futures.immediateFailedFuture(new MissingSchemaSourceException(sourceId, "No source registered"))
- : Futures.immediateFuture(new DelegatedYangTextSource(sourceId, info.getYangTextCharSource()));
+ return info == null ? null : new DelegatedYangTextSource(sourceId, info.getYangTextCharSource());
+ }
+
+ @Override
+ public YangTextSource getYangTextSource(final SourceIdentifier sourceId) throws MissingSchemaSourceException {
+ final var source = yangTextSource(sourceId);
+ if (source == null) {
+ throw new MissingSchemaSourceException(sourceId, "No source registered");
+ }
+ return source;
}
@Override
import com.google.common.annotations.Beta;
import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
+import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
@Beta
+@NonNullByDefault
public abstract class ForwardingModuleInfoSnapshot extends ForwardingObject implements ModuleInfoSnapshot {
@Override
protected abstract ModuleInfoSnapshot delegate();
}
@Override
- public @NonNull EffectiveModelContext modelContext() {
+ public EffectiveModelContext modelContext() {
return delegate().modelContext();
}
@Override
- public ListenableFuture<? extends YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
- return delegate().getSource(sourceIdentifier);
+ public @Nullable YangTextSource yangTextSource(final SourceIdentifier sourceId) {
+ return delegate().yangTextSource(sourceId);
+ }
+
+ @Override
+ public YangTextSource getYangTextSource(final SourceIdentifier sourceId) throws MissingSchemaSourceException {
+ return delegate().getYangTextSource(sourceId);
}
}