Remove deprecated SchemaContextFactory methods 94/80594/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Feb 2019 10:21:25 +0000 (11:21 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Feb 2019 10:21:25 +0000 (11:21 +0100)
Specification of StatementParserMode and supported features has been
moved to SchemaContextFactoryConfiguration, now remove deprecated
compatibility methods.

Change-Id: I6e3710c0791527a0ab930f879550b447e1dd1490
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaContextFactory.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactory.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaContextResolver.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/OpenconfigVerSharedSchemaRepositoryTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java

index 779a1467e10e86340ec67eebff9e8dad5a3d1db4..c22335113efaef862768d4292cd968622346b1cf 100644 (file)
@@ -10,15 +10,12 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
-import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
- * An asynchronous factory for building {@link SchemaContext} instances based on
- * a specification of what {@link SourceIdentifier}s are required and dynamic
- * recursive resolution.
+ * An asynchronous factory for building {@link SchemaContext} instances based on a specification of what
+ * {@link SourceIdentifier}s are required and dynamic recursive resolution.
  */
 @Beta
 public interface SchemaContextFactory {
@@ -30,50 +27,4 @@ public interface SchemaContextFactory {
      *         of the schema context failed.
      */
     @NonNull ListenableFuture<SchemaContext> createSchemaContext(@NonNull Collection<SourceIdentifier> requiredSources);
-
-    /**
-     * Create a new schema context containing specified sources, pulling in any dependencies they may have.
-     *
-     * @param requiredSources a collection of sources which are required to be present
-     * @param statementParserMode mode of statement parser
-     * @return A future which will produce a schema context, or fail with an explanation why the creation
-     *         of the schema context failed.
-     * @deprecated Use SchemaContextFactoryConfiguration instead.
-     */
-    @Deprecated
-    default @NonNull ListenableFuture<SchemaContext> createSchemaContext(
-            final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode) {
-        return createSchemaContext(requiredSources, statementParserMode, null);
-    }
-
-    /**
-     * Create a new schema context containing specified sources, pulling in any dependencies they may have.
-     *
-     * @param requiredSources a collection of sources which are required to be present
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @return A future which will produce a schema context, or fail with an explanation why the creation of the schema
-     *         context failed.
-     * @deprecated Use SchemaContextFactoryConfiguration instead.
-     */
-    @Deprecated
-    default @NonNull ListenableFuture<SchemaContext> createSchemaContext(
-            final @NonNull Collection<SourceIdentifier> requiredSources, final Set<QName> supportedFeatures) {
-        return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE, supportedFeatures);
-    }
-
-    /**
-     * Create a new schema context containing specified sources, pulling in any dependencies they may have.
-     *
-     * @param requiredSources a collection of sources which are required to be present
-     * @param statementParserMode mode of statement parser
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @return A future which will produce a schema context, or fail with an explanation why the creation of the schema
-     *         context failed.
-     * @deprecated Use SchemaContextFactoryConfiguration instead.
-     */
-    @Deprecated
-    @NonNull ListenableFuture<SchemaContext> createSchemaContext(Collection<SourceIdentifier> requiredSources,
-            StatementParserMode statementParserMode, Set<QName> supportedFeatures);
 }
index 466b0387fb6efd2d5791c138f51b0ab2e0fdbedd..3321c6e98723ead656446ab7805ba5e1cb9e2c98 100644 (file)
@@ -34,7 +34,6 @@ import java.util.Set;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
@@ -67,18 +66,6 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
         this.config = requireNonNull(config);
     }
 
-    @Override
-    @Deprecated
-    public @NonNull ListenableFuture<SchemaContext> createSchemaContext(
-            final Collection<SourceIdentifier> requiredSources,
-            final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
-        return createSchemaContext(requiredSources,
-                statementParserMode == StatementParserMode.SEMVER_MODE ? semVerCache : revisionCache,
-                new AssembleSources(SchemaContextFactoryConfiguration.builder()
-                        .setFilter(config.getSchemaSourceFilter()).setStatementParserMode(statementParserMode)
-                        .setSupportedFeatures(supportedFeatures).build()));
-    }
-
     @Override
     public @NonNull ListenableFuture<SchemaContext> createSchemaContext(
             final @NonNull Collection<SourceIdentifier> requiredSources) {
index dba5d2e1a739eaf08fee6ff736f10624f0566c96..cadde662b8eb29a58fd458cd101d1ddfa532308e 100644 (file)
@@ -234,7 +234,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
             } while (ver != version);
 
             while (true) {
-                final ListenableFuture<SchemaContext> f = factory.createSchemaContext(sources, statementParserMode);
+                final ListenableFuture<SchemaContext> f = factory.createSchemaContext(sources);
                 try {
                     sc = Optional.of(f.get());
                     break;
@@ -300,7 +300,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
             throws SchemaResolutionException {
         final ListenableFuture<SchemaContext> future = repository
                 .createSchemaContextFactory(config(statementParserMode))
-                .createSchemaContext(ImmutableSet.copyOf(requiredSources), statementParserMode);
+                .createSchemaContext(ImmutableSet.copyOf(requiredSources));
 
         try {
             return future.get();
index 166dccabdc4e6a661efff3995afa4d590c04edee..0ff5cec342c81da310aa48b47f1b31ae96df35a4 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
@@ -42,16 +43,17 @@ public class OpenconfigVerSharedSchemaRepositoryTest {
         semVer.register(sharedSchemaRepository);
         semVer.setResult();
 
-        final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory();
+        final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory(
+            SchemaContextFactoryConfiguration.builder().setStatementParserMode(StatementParserMode.SEMVER_MODE)
+            .build());
 
-        final ListenableFuture<SchemaContext> inetAndTopologySchemaContextFuture =
-                fact.createSchemaContext(ImmutableList.of(bar.getId(), foo.getId(), semVer.getId()),
-                    StatementParserMode.SEMVER_MODE);
+        final ListenableFuture<SchemaContext> inetAndTopologySchemaContextFuture = fact.createSchemaContext(
+            ImmutableList.of(bar.getId(), foo.getId(), semVer.getId()));
         assertTrue(inetAndTopologySchemaContextFuture.isDone());
         assertSchemaContext(inetAndTopologySchemaContextFuture.get(), 3);
 
-        final ListenableFuture<SchemaContext> barSchemaContextFuture = fact
-                .createSchemaContext(ImmutableList.of(bar.getId(), semVer.getId()), StatementParserMode.SEMVER_MODE);
+        final ListenableFuture<SchemaContext> barSchemaContextFuture = fact.createSchemaContext(
+            ImmutableList.of(bar.getId(), semVer.getId()));
         assertTrue(barSchemaContextFuture.isDone());
         assertSchemaContext(barSchemaContextFuture.get(), 2);
     }
index f6832e463a92996825226316bff2037bd2bd6626..081f9e971862bef9d027acacfd3c426e7b02329a 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToASTTransformer;
@@ -42,9 +43,10 @@ public class SharedSchemaRepositoryWithFeaturesTest {
         foobar.register(sharedSchemaRepository);
         foobar.setResult();
 
-        final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory();
         final ListenableFuture<SchemaContext> testSchemaContextFuture =
-                fact.createSchemaContext(ImmutableList.of(foobar.getId()), supportedFeatures);
+                sharedSchemaRepository.createSchemaContextFactory(
+                SchemaContextFactoryConfiguration.builder().setSupportedFeatures(supportedFeatures).build())
+                .createSchemaContext(ImmutableList.of(foobar.getId()));
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.get(), 1);
 
@@ -115,8 +117,6 @@ public class SharedSchemaRepositoryWithFeaturesTest {
 
     @Test
     public void testSharedSchemaRepositoryWithNoFeaturesSupported() throws Exception {
-        final Set<QName> supportedFeatures = ImmutableSet.of();
-
         final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
                 "shared-schema-repo-with-features-test");
 
@@ -125,9 +125,10 @@ public class SharedSchemaRepositoryWithFeaturesTest {
         foobar.register(sharedSchemaRepository);
         foobar.setResult();
 
-        final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory();
         final ListenableFuture<SchemaContext> testSchemaContextFuture =
-                fact.createSchemaContext(ImmutableList.of(foobar.getId()), supportedFeatures);
+                sharedSchemaRepository.createSchemaContextFactory(
+                    SchemaContextFactoryConfiguration.builder().setSupportedFeatures(ImmutableSet.of()).build())
+                .createSchemaContext(ImmutableList.of(foobar.getId()));
         assertTrue(testSchemaContextFuture.isDone());
         assertSchemaContext(testSchemaContextFuture.get(), 1);