Promote SchemaSourceRepresentation
[yangtools.git] / plugin / plugin-generator-api / src / main / java / org / opendaylight / yangtools / plugin / generator / api / ModuleResourceResolver.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 java.util.Optional;
11 import org.opendaylight.yangtools.yang.model.api.ModuleLike;
12 import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
13 import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
14
15 /**
16  * An SPI-level interface to find the schema source for a particular YANG module, as packaged in the final artifact.
17  * The module must be part of the current resolution context.
18  */
19 public interface ModuleResourceResolver {
20     /**
21      * Find the path of the packaged resource which corresponds to the specified module in the specified representation.
22      *
23      * @param module Requested module
24      * @param representation Requested representation
25      * @return Path to packaged resource
26      * @throws NullPointerException if any argument is {@code null}
27      * @throws IllegalArgumentException if the requested representation is not supported by this resolver
28      */
29     Optional<String> findModuleResourcePath(ModuleLike module, Class<? extends SourceRepresentation> representation);
30
31     default Optional<String> findModuleYangTextResourcePath(final ModuleLike module) {
32         return findModuleResourcePath(module, YangTextSource.class);
33     }
34 }