BUG-7568: cleanup BasicCodeGenerator 77/62977/19
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Sep 2017 14:51:11 +0000 (16:51 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 11 Oct 2017 17:28:43 +0000 (17:28 +0000)
This is an API-incompatible change to ensure that only the correct method
is implemented.

Change-Id: I59469fddda3b71972639f5c28a3530796de6de28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-maven-plugin-spi/src/main/java/org/opendaylight/yangtools/yang2sources/spi/BasicCodeGenerator.java
yang/yang-maven-plugin-spi/src/test/java/org/opendaylight/yangtools/yang2sources/spi/CodeGeneratorTestImpl.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesMojo.java
yang/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/GenerateSourcesTest.java

index c50f176cd49ae6863f5883f9398a9f6419f9e0fb..9c07db36be5069be61006f619ee3f72137bd71bb 100644 (file)
@@ -22,25 +22,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  * a logger instance around.
  */
 public interface BasicCodeGenerator {
-    /**
-     * Generate sources from provided {@link SchemaContext}.
-     *
-     * @param context
-     *            parsed from YANG files
-     * @param outputBaseDir
-     *            expected output directory for generated sources configured by
-     *            user
-     * @param currentModules
-     *            YANG modules parsed from yangFilesRootDir
-     * @return collection of files that were generated from schema context
-     * @throws IOException
-     *
-     * @deprecated Implement {@link #generateSources(SchemaContext, File, Set, Function)} instead.
-     */
-    @Deprecated
-    Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules)
-            throws IOException;
-
     /**
      * Generate sources from provided {@link SchemaContext}.
      *
@@ -55,11 +36,8 @@ public interface BasicCodeGenerator {
      *            Function converting a local module to the packaged resource path
      * @return collection of files that were generated from schema context
      */
-    default Collection<File> generateSources(final SchemaContext context, final File outputBaseDir,
-            final Set<Module> currentModules,
-            final Function<Module, Optional<String>> moduleResourcePathResolver) throws IOException {
-        return generateSources(context, outputBaseDir, currentModules);
-    }
+    Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules,
+            Function<Module, Optional<String>> moduleResourcePathResolver) throws IOException;
 
     /**
      * Provided map contains all configuration that was set in pom for code
index 460192660340eed8a61c0e60fad8a44d2f51ce28..e9a8db6b6a9181b84d36feffb7a62c20b35e1d23 100644 (file)
@@ -8,9 +8,12 @@
 package org.opendaylight.yangtools.yang2sources.spi;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
 import org.apache.maven.project.MavenProject;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -22,11 +25,11 @@ public class CodeGeneratorTestImpl implements BasicCodeGenerator, MavenProjectAw
     private static final Logger LOG = LoggerFactory.getLogger(CodeGeneratorTestImpl.class);
 
     @Override
-    public Collection<File> generateSources(final SchemaContext context,
-            final File outputBaseDir, final Set<Module> currentModuleBuilders) {
+    public Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules,
+            Function<Module, Optional<String>> moduleResourcePathResolver) throws IOException {
         LOG.debug("{} generateSources:context: {}", getClass().getCanonicalName(), context);
         LOG.debug("{} generateSources:outputBaseDir: {}", getClass().getCanonicalName(), outputBaseDir);
-        LOG.debug("{} generateSources:currentModuleBuilders: {}", getClass().getCanonicalName(), currentModuleBuilders);
+        LOG.debug("{} generateSources:currentModules: {}", getClass().getCanonicalName(), currentModules);
         return null;
     }
 
index 311acc54953ee6af6c8f9d939c008fa25a08c721..7ad534a6de0f245052e568d1b44546bc54079e82 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import java.util.function.Function;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -41,7 +42,7 @@ import org.sonatype.plexus.build.incremental.BuildContext;
  * <li>For each {@link BasicCodeGenerator} from {@link #codeGenerators}:
  * <ol>
  * <li>Instantiate using default constructor</li>
- * <li>Call {@link BasicCodeGenerator#generateSources(SchemaContext, File, Set)}</li>
+ * <li>Call {@link BasicCodeGenerator#generateSources(SchemaContext, File, Set, Function)}</li>
  * </ol></li>
  * </ol>
  */
index 53fb962ce7821da0be683d378efa2eaf1131d814..e86c5e2025193cea3618e342872b6c242b165202 100644 (file)
@@ -23,7 +23,9 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
+import java.util.function.Function;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.project.MavenProject;
@@ -90,14 +92,6 @@ public class GenerateSourcesTest {
         private static File resourceBaseDir;
         private static MavenProject project;
 
-        @Override
-        public Collection<File> generateSources(final SchemaContext context, final File outputBaseDir,
-                final Set<Module> currentModules) throws IOException {
-            called++;
-            outputDir = outputBaseDir;
-            return Lists.newArrayList();
-        }
-
         @Override
         public void setAdditionalConfig(final Map<String, String> additionalConfiguration) {
             GeneratorMock.additionalCfg = additionalConfiguration;
@@ -113,6 +107,14 @@ public class GenerateSourcesTest {
         public void setMavenProject(final MavenProject project) {
             GeneratorMock.project = project;
         }
+
+        @Override
+        public Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules,
+                Function<Module, Optional<String>> moduleResourcePathResolver) throws IOException {
+            called++;
+            outputDir = outputBaseDir;
+            return Lists.newArrayList();
+        }
     }
 
 }