2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.plugin.generator.api;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.Table;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 * Interface implemented by plugins which can generate files from a {@link EffectiveModelContext}.
21 * @author Robert Varga
25 public interface FileGenerator {
27 * Indicate import resolution mode this code generator requires. Default implementation indicates
28 * {@link ImportResolutionMode#REVISION_EXACT_OR_LATEST}.
30 * @return Required import resolution mode, null if the code generator does not care.
32 default ImportResolutionMode importResolutionMode() {
33 return ImportResolutionMode.REVISION_EXACT_OR_LATEST;
37 * Generate files from a {@link SchemaContext}, being aware the that specific modules are local to the current
38 * project being processed.
41 * Implementations of this interface must not interact with project directory directly, but rather supply the files
42 * generated as a set of {@link GeneratedFile}s. The caller of this method will use these to integrate with build
43 * management to ensure proper dependency tracking is performed.
45 * @param context SchemaContext to examine
46 * @param localModules Modules local to the project
47 * @param moduleResourcePathResolver Module-to-resource path resolver
48 * @return The set of generated files.
49 * @throws FileGeneratorException if anything bad happens
51 Table<GeneratedFileType, GeneratedFilePath, GeneratedFile> generateFiles(EffectiveModelContext context,
52 Set<Module> localModules, ModuleResourceResolver moduleResourcePathResolver) throws FileGeneratorException;
55 * {@link EffectiveModelContext} can be assembled in multiple ways, we hold known modes here.
58 enum ImportResolutionMode {
60 * Standard, RFC6020 and RFC7950 compliant mode. Imports are satisfied by exact revision match (if specified),
61 * or by latest available revision.
63 REVISION_EXACT_OR_LATEST;