Promote SchemaSourceRepresentation
[yangtools.git] / yang / yang-repo-spi / src / main / java / org / opendaylight / yangtools / yang / model / repo / spi / AbstractSchemaRepository.java
index 9d95628b50ab17f758f987e90c41cf66acf41291..49012e4260b3668b05ed110036d25044d9d95cb6 100644 (file)
@@ -29,10 +29,10 @@ import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +49,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
      * a specific representation of a source.
      */
     @GuardedBy("this")
-    private final Map<SourceIdentifier, ListMultimap<Class<? extends SchemaSourceRepresentation>,
+    private final Map<SourceIdentifier, ListMultimap<Class<? extends SourceRepresentation>,
             SchemaSourceRegistration>> sources = new HashMap<>();
 
     /*
@@ -58,23 +58,23 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     @GuardedBy("this")
     private final List<SchemaListenerRegistration> listeners = new ArrayList<>();
 
-    private static <T extends SchemaSourceRepresentation> ListenableFuture<T> fetchSource(final SourceIdentifier id,
-            final Iterator<SchemaSourceRegistration> it) {
+    private static <T extends SourceRepresentation> ListenableFuture<T> fetchSource(
+            final SourceIdentifier sourceId, final Iterator<SchemaSourceRegistration> it) {
         final var reg = it.next();
         @SuppressWarnings("unchecked")
         final var provider = (SchemaSourceProvider<T>) reg.provider();
 
-        return Futures.catchingAsync(provider.getSource(id), Throwable.class, input -> {
+        return Futures.catchingAsync(provider.getSource(sourceId), Throwable.class, input -> {
             LOG.debug("Failed to acquire source from {}", reg, input);
             if (it.hasNext()) {
-                return fetchSource(id, it);
+                return fetchSource(sourceId, it);
             }
-            throw new MissingSchemaSourceException("All available providers exhausted", id, input);
+            throw new MissingSchemaSourceException("All available providers exhausted", sourceId, input);
         }, MoreExecutors.directExecutor());
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> ListenableFuture<T> getSchemaSource(final SourceIdentifier id,
+    public <T extends SourceRepresentation> ListenableFuture<T> getSchemaSource(final SourceIdentifier id,
             final Class<T> representation) {
         final ArrayList<SchemaSourceRegistration> sortedSchemaSourceRegistrations;
 
@@ -94,7 +94,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
         final var regs = sortedSchemaSourceRegistrations.iterator();
         if (!regs.hasNext()) {
             return immediateFailedFluentFuture(new MissingSchemaSourceException(
-                        "No providers for source " + id + " representation " + representation + " available", id));
+                "No providers for source " + id + " representation " + representation + " available", id));
         }
 
         final ListenableFuture<T> fetchSourceFuture = fetchSource(id, regs);
@@ -145,7 +145,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> Registration registerSchemaSource(
+    public <T extends SourceRepresentation> Registration registerSchemaSource(
             final SchemaSourceProvider<? super T> provider, final PotentialSchemaSource<T> source) {
         final var ret = new SchemaSourceRegistration(source.cachedReference(), provider);
         addSource(ret);