Remove ImportResolutionMode.SEMVER_LATEST
[yangtools.git] / plugin / plugin-generator-api / src / main / java / org / opendaylight / yangtools / plugin / generator / api / FileGenerator.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.plugin.generator.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.Table;
12 import java.util.Set;
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;
17
18 /**
19  * Interface implemented by plugins which can generate files from a {@link EffectiveModelContext}.
20  *
21  * @author Robert Varga
22  */
23 @Beta
24 @NonNullByDefault
25 public interface FileGenerator {
26     /**
27      * Indicate import resolution mode this code generator requires. Default implementation indicates
28      * {@link ImportResolutionMode#REVISION_EXACT_OR_LATEST}.
29      *
30      * @return Required import resolution mode, null if the code generator does not care.
31      */
32     default ImportResolutionMode importResolutionMode() {
33         return ImportResolutionMode.REVISION_EXACT_OR_LATEST;
34     }
35
36     /**
37      * Generate files from a {@link SchemaContext}, being aware the that specific modules are local to the current
38      * project being processed.
39      *
40      * <p>
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.
44      *
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
50      */
51     Table<GeneratedFileType, GeneratedFilePath, GeneratedFile> generateFiles(EffectiveModelContext context,
52             Set<Module> localModules, ModuleResourceResolver moduleResourcePathResolver) throws FileGeneratorException;
53
54     /**
55      * {@link EffectiveModelContext} can be assembled in multiple ways, we hold known modes here.
56      */
57     @Beta
58     enum ImportResolutionMode {
59         /**
60          * Standard, RFC6020 and RFC7950 compliant mode. Imports are satisfied by exact revision match (if specified),
61          * or by latest available revision.
62          */
63         REVISION_EXACT_OR_LATEST;
64     }
65 }