From 0a2d7366079b93c52d8d1ccf520c5ec2b84d6472 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 3 Nov 2017 14:00:56 +0100 Subject: [PATCH] YANGTOOLS-825: extend plugin SPI with import resolution mode This patch adds the basic API needed for codegen plugins to express their desired import resolution mode. The default implementation results in RFC6020/7950 compliant mode. Change-Id: I60936171b984dab503e1933b21dbcb5bd68278c8 Signed-off-by: Robert Varga --- .../yang2sources/spi/BasicCodeGenerator.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/yang/yang-maven-plugin-spi/src/main/java/org/opendaylight/yangtools/yang2sources/spi/BasicCodeGenerator.java b/yang/yang-maven-plugin-spi/src/main/java/org/opendaylight/yangtools/yang2sources/spi/BasicCodeGenerator.java index 9c07db36be..364aed252d 100644 --- a/yang/yang-maven-plugin-spi/src/main/java/org/opendaylight/yangtools/yang2sources/spi/BasicCodeGenerator.java +++ b/yang/yang-maven-plugin-spi/src/main/java/org/opendaylight/yangtools/yang2sources/spi/BasicCodeGenerator.java @@ -22,6 +22,20 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; * a logger instance around. */ public interface BasicCodeGenerator { + enum ImportResolutionMode { + /** + * Standard, RFC6020 and RFC7950 compliant mode. Imports are satisfied by exact revision match (if specified), + * or by latest available revision. + */ + REVISION_EXACT_OR_LATEST, + /** + * Semantic version based mode. Imports which specify a semantic version (via the OpenConfig extension) will + * be satisfied by module which exports the latest compatible revision. Imports which do not specify semantic + * version will be resolved just as they would be via {@link #REVISION_EXACT_OR_LATEST}. + */ + SEMVER_LATEST, + } + /** * Generate sources from provided {@link SchemaContext}. * @@ -50,4 +64,14 @@ public interface BasicCodeGenerator { * in resulting jar. Feel free to add necessary resources. */ void setResourceBaseDir(File resourceBaseDir); + + /** + * Indicate import resolution mode this code generator requires. Default implementation indicates + * {@link ImportResolutionMode#REVISION_EXACT_OR_LATEST}. + * + * @return Import resolution mode. + */ + default ImportResolutionMode getImportResolutionMode() { + return ImportResolutionMode.REVISION_EXACT_OR_LATEST; + } } -- 2.36.6