001package jmri.jmrit.logixng.util.parser;
002
003import jmri.JmriException;
004import jmri.jmrit.logixng.SymbolTable;
005
006/**
007 * An expression that takes a parameter.
008 * This interface are used for ExpressionNodeFunction
009 */
010public interface ExpressionNodeWithParameter extends ExpressionNode {
011
012    /** {@inheritDoc} */
013    @Override
014    default Object calculate(SymbolTable symbolTable) throws JmriException {
015        throw new UnsupportedOperationException("Not implemented. Use calculate(parameter, symbolTable) instead");
016    }
017    
018    /**
019     * Calculate the expression from a parameter.
020     * @param parameter the parameter
021     * @param symbolTable the symbol table
022     * @return the result
023     * @throws JmriException if an error occurs
024     */
025    Object calculate(Object parameter, SymbolTable symbolTable) throws JmriException;
026    
027    /**
028     * Assign a value to this expression from a parameter.
029     * @param parameter the parameter
030     * @param symbolTable the symbol table
031     * @param value the value to assign
032     * @throws jmri.JmriException if an error occurs
033     */
034    default void assignValue(Object parameter, SymbolTable symbolTable, Object value) throws JmriException {
035        throw new UnsupportedOperationException("This expression can't be assigned");
036    }
037    
038}