001package io.jstach.jstachio.spi;
002
003import java.util.List;
004
005import io.jstach.jstachio.Template;
006import io.jstach.jstachio.TemplateConfig;
007
008/**
009 * A {@link java.util.ServiceLoader} interface for finding {@link Template}s.
010 * <p>
011 * In non modular applications the Templates can be found using this interface and the
012 * {@link java.util.ServiceLoader} mechanism through the <code>META-INF/services</code>
013 * file as the code generator generates the services file. However in modular applications
014 * this is not possible as the implementations are described in the module-info.java and
015 * the code generator does not touch that.
016 * <p>
017 * Regardless of modular or not the generated META-INF/services also might give hints to
018 * Graal native compilation for reflective access to the templates.
019 *
020 * @author agentgt
021 */
022public interface TemplateProvider {
023
024        /**
025         * Provides a list of instantiated renderers.
026         * @param templateConfig template collaborators.
027         * @return a list of renderers. An empty list would mean none were found.
028         */
029        public List<Template<?>> provideTemplates(TemplateConfig templateConfig);
030
031        /**
032         * Provides templates with empty config.
033         * @return a list of templates. An empty list would mean none were fond.
034         */
035        default List<Template<?>> provideTemplates() {
036                return provideTemplates(TemplateConfig.empty());
037        }
038
039}