Add generalized FileGenerator interface
[yangtools.git] / plugin / plugin-generator-api / src / main / java / org / opendaylight / yangtools / plugin / generator / api / ModuleResourceResolver.java
diff --git a/plugin/plugin-generator-api/src/main/java/org/opendaylight/yangtools/plugin/generator/api/ModuleResourceResolver.java b/plugin/plugin-generator-api/src/main/java/org/opendaylight/yangtools/plugin/generator/api/ModuleResourceResolver.java
new file mode 100644 (file)
index 0000000..c97d03e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.plugin.generator.api;
+
+import com.google.common.annotations.Beta;
+import java.util.Optional;
+import org.opendaylight.yangtools.yang.model.api.ModuleLike;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+
+/**
+ * An SPI-level interface to find the schema source for a particular YANG module, as packaged in the final artifact.
+ * The module must be part of the current resolution context.
+ */
+@Beta
+public interface ModuleResourceResolver {
+    /**
+     * Find the path of the packaged resource which corresponds to the specified module in the specified representation.
+     *
+     * @param module Requested module
+     * @param representation Requested representation
+     * @return Path to packaged resource
+     * @throws NullPointerException if any argument is null
+     * @throws IllegalArgumentException if the requested representation is not supported by this resolver
+     */
+    Optional<String> findModuleResourcePath(ModuleLike module,
+        Class<? extends SchemaSourceRepresentation> representation);
+
+    default Optional<String> findModuleYangTextResourcePath(final ModuleLike module) {
+        return findModuleResourcePath(module, YangTextSchemaSource.class);
+    }
+}