BUG-7568: expose file name mapping function
[yangtools.git] / yang / yang-maven-plugin-spi / src / main / java / org / opendaylight / yangtools / yang2sources / spi / BasicCodeGenerator.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang2sources.spi;
9
10 import java.io.File;
11 import java.io.IOException;
12 import java.util.Collection;
13 import java.util.Map;
14 import java.util.Optional;
15 import java.util.Set;
16 import java.util.function.Function;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19
20 /**
21  * Maven 3.1.x and newer uses SLF4J internally, which means we do not need to pass
22  * a logger instance around.
23  */
24 public interface BasicCodeGenerator {
25     /**
26      * Generate sources from provided {@link SchemaContext}
27      *
28      * @param context
29      *            parsed from YANG files
30      * @param outputBaseDir
31      *            expected output directory for generated sources configured by
32      *            user
33      * @param currentModules
34      *            YANG modules parsed from yangFilesRootDir
35      * @return collection of files that were generated from schema context
36      * @throws IOException
37      *
38      * @deprecated Implement {@link #generateSources(SchemaContext, File, Set, Function)} instead.
39      */
40     @Deprecated
41     Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules)
42             throws IOException;
43
44     /**
45      * Generate sources from provided {@link SchemaContext}
46      *
47      * @param context
48      *            parsed from YANG files
49      * @param outputBaseDir
50      *            expected output directory for generated sources configured by
51      *            user
52      * @param currentModules
53      *            YANG modules parsed from yangFilesRootDir
54      * @param moduleResourcePathResolver
55      *            Function converting a local module to the packaged resource path
56      * @return collection of files that were generated from schema context
57      * @throws IOException
58      */
59     default Collection<File> generateSources(final SchemaContext context, final File outputBaseDir,
60             final Set<Module> currentModules,
61             final Function<Module, Optional<String>> moduleResourcePathResolver) throws IOException {
62         return generateSources(context, outputBaseDir, currentModules);
63     }
64
65     /**
66      * Provided map contains all configuration that was set in pom for code
67      * generator in additionalConfiguration tag
68      *
69      * @param additionalConfiguration
70      */
71     void setAdditionalConfig(Map<String, String> additionalConfiguration);
72
73     /**
74      * Provided folder is marked as resources and its content will be packaged
75      * in resulting jar. Feel free to add necessary resources
76      *
77      * @param resourceBaseDir
78      */
79     void setResourceBaseDir(File resourceBaseDir);
80 }