2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang2sources.spi;
11 import java.io.IOException;
12 import java.util.Collection;
15 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
16 import org.opendaylight.yangtools.yang.model.api.Module;
19 * Maven 3.1.x and newer uses SLF4J internally, which means we do not need to pass a logger instance around.
21 public interface BasicCodeGenerator {
22 enum ImportResolutionMode {
24 * Standard, RFC6020 and RFC7950 compliant mode. Imports are satisfied by exact revision match (if specified),
25 * or by latest available revision.
27 REVISION_EXACT_OR_LATEST,
29 * Semantic version based mode. Imports which specify a semantic version (via the OpenConfig extension) will
30 * be satisfied by module which exports the latest compatible revision. Imports which do not specify semantic
31 * version will be resolved just as they would be via {@link #REVISION_EXACT_OR_LATEST}.
37 * Generate sources from provided {@link EffectiveModelContext}.
40 * parsed from YANG files
41 * @param outputBaseDir
42 * expected output directory for generated sources configured by
44 * @param currentModules
45 * YANG modules parsed from yangFilesRootDir
46 * @param moduleResourcePathResolver
47 * Function converting a local module to the packaged resource path
48 * @return collection of files that were generated from schema context
50 Collection<File> generateSources(EffectiveModelContext context, File outputBaseDir, Set<Module> currentModules,
51 ModuleResourceResolver moduleResourcePathResolver) throws IOException;
54 * Provided map contains all configuration that was set in pom for code
55 * generator in additionalConfiguration tag.
57 void setAdditionalConfig(Map<String, String> additionalConfiguration);
60 * Provided folder is marked as resources and its content will be packaged
61 * in resulting jar. Feel free to add necessary resources.
63 void setResourceBaseDir(File resourceBaseDir);
66 * Indicate import resolution mode this code generator requires. Default implementation indicates
67 * {@link ImportResolutionMode#REVISION_EXACT_OR_LATEST}.
69 * @return Required import resolution mode, null if the code generator does not care.
71 // FIXME: This is not really extensible, we should be returning a collection of acceptable modes, or have some sort
72 // of two-step negotiation protocol:
73 // - Optional<ImportResolutionMode> suggestImportResolutionMode();
74 // - boolean isImportResolutionModeAcceptable(ImportResolutionMode);
75 // Let's go with something hacky until we figure out exact requirements.
76 default ImportResolutionMode getImportResolutionMode() {
77 return ImportResolutionMode.REVISION_EXACT_OR_LATEST;