001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.tools.template_engine;
003
004import java.util.Collection;
005
006import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
007
008/**
009 * Interface for objects that can be used with a template to generate a string.
010 * <p>
011 * Provides the necessary information for the template to be applied.
012 */
013public interface TemplateEngineDataProvider {
014    /**
015     * Get the collection of all keys that can be mapped to values.
016     * @return all keys that can be mapped to values
017     */
018    Collection<String> getTemplateKeys();
019
020    /**
021     * Map a key to a value given the properties of the object.
022     * @param key the key to map
023     * @param special if the key is a "special:*" keyword that is used
024     * to get certain information or automated behavior
025     * @return a value that the key is mapped to or "special" information in case {@code special} is true
026     */
027    Object getTemplateValue(String key, boolean special);
028
029    /**
030     * Check if a condition holds for the object represented by this {@link TemplateEngineDataProvider}.
031     * @param condition the condition to check (which is a search expression)
032     * @return true if the condition holds
033     */
034    boolean evaluateCondition(Match condition);
035}