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.collect.Table;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
14 import org.opendaylight.yangtools.yang.model.api.Module;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 * Interface implemented by plugins which can generate files from a {@link EffectiveModelContext}.
20 * @author Robert Varga
23 public interface FileGenerator {
25 * Indicate import resolution mode this code generator requires. Default implementation indicates
26 * {@link ImportResolutionMode#REVISION_EXACT_OR_LATEST}.
29 * Default implementation returns {@link ImportResolutionMode#REVISION_EXACT_OR_LATEST}.
31 * @return Required import resolution mode.
33 default ImportResolutionMode importResolutionMode() {
34 return ImportResolutionMode.REVISION_EXACT_OR_LATEST;
38 * Generate files from a {@link SchemaContext}, being aware the that specific modules are local to the current
39 * project being processed.
42 * Implementations of this interface must not interact with project directory directly, but rather supply the files
43 * generated as a set of {@link GeneratedFile}s. The caller of this method will use these to integrate with build
44 * management to ensure proper dependency tracking is performed.
46 * @param context SchemaContext to examine
47 * @param localModules Modules local to the project
48 * @param moduleResourcePathResolver Module-to-resource path resolver
49 * @return The set of generated files.
50 * @throws FileGeneratorException if anything bad happens
52 Table<GeneratedFileType, GeneratedFilePath, GeneratedFile> generateFiles(EffectiveModelContext context,
53 Set<Module> localModules, ModuleResourceResolver moduleResourcePathResolver) throws FileGeneratorException;
56 * {@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;