/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang2sources.spi; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Set; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.plugin.generator.api.FileGenerator; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; /** * Maven 3.1.x and newer uses SLF4J internally, which means we do not need to pass a logger instance around. * * @deprecated Use {@link FileGenerator} instead. */ @Deprecated 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(FileGenerator.ImportResolutionMode.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(FileGenerator.ImportResolutionMode.SEMVER_LATEST); private final FileGenerator.@NonNull ImportResolutionMode fileGeneratorMode; ImportResolutionMode(final FileGenerator.@NonNull ImportResolutionMode fileGeneratorMode) { this.fileGeneratorMode = fileGeneratorMode; } /** * Return {@link FileGenerator.ImportResolutionMode} equivalent of this mode. * * @return {@link FileGenerator.ImportResolutionMode} equivalent of this mode */ public final FileGenerator.@NonNull ImportResolutionMode toFileGeneratorMode() { return fileGeneratorMode; } } /** * Generate sources from provided {@link EffectiveModelContext}. * * @param context * parsed from YANG files * @param outputBaseDir * expected output directory for generated sources configured by * user * @param currentModules * YANG modules parsed from yangFilesRootDir * @param moduleResourcePathResolver * Function converting a local module to the packaged resource path * @return collection of files that were generated from schema context */ Collection generateSources(EffectiveModelContext context, File outputBaseDir, Set currentModules, ModuleResourceResolver moduleResourcePathResolver) throws IOException; /** * Provided map contains all configuration that was set in pom for code * generator in additionalConfiguration tag. */ void setAdditionalConfig(Map additionalConfiguration); /** * Provided folder is marked as resources and its content will be packaged * 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 Required import resolution mode, null if the code generator does not care. */ // FIXME: This is not really extensible, we should be returning a collection of acceptable modes, or have some sort // of two-step negotiation protocol: // - Optional suggestImportResolutionMode(); // - boolean isImportResolutionModeAcceptable(ImportResolutionMode); // Let's go with something hacky until we figure out exact requirements. default ImportResolutionMode getImportResolutionMode() { return ImportResolutionMode.REVISION_EXACT_OR_LATEST; } }