Class MapBasedOperatorDictionary

  • All Implemented Interfaces:
    OperatorDictionaryIfc

    public class MapBasedOperatorDictionary
    extends java.lang.Object
    implements OperatorDictionaryIfc
    A default case-insensitive implementation of the operator dictionary that uses a local Map.Entry<String,OperatorIfc> for storage.
    • Constructor Detail

      • MapBasedOperatorDictionary

        public MapBasedOperatorDictionary()
    • Method Detail

      • ofOperators

        public static OperatorDictionaryIfc ofOperators​(java.util.Map.Entry<java.lang.String,​OperatorIfc>... operators)
        Creates a new operator dictionary with the specified list of operators.
        Parameters:
        operators - variable number of arguments that specify the operator names and definitions that will initially be added.
        Returns:
        A newly created operator dictionary with the specified operators.
      • addOperator

        public void addOperator​(java.lang.String operatorString,
                                OperatorIfc operator)
        Description copied from interface: OperatorDictionaryIfc
        Allows to add an operator to the dictionary. Implementation is optional, if you have a fixed set of operators, this method can throw an exception.
        Specified by:
        addOperator in interface OperatorDictionaryIfc
        Parameters:
        operatorString - The operator name.
        operator - The operator implementation.
      • getPrefixOperator

        public OperatorIfc getPrefixOperator​(java.lang.String operatorString)
        Description copied from interface: OperatorDictionaryIfc
        Get the operator definition for a prefix operator name.
        Specified by:
        getPrefixOperator in interface OperatorDictionaryIfc
        Parameters:
        operatorString - The name of the operator.
        Returns:
        The operator definition or null if no operator was found.
      • getPostfixOperator

        public OperatorIfc getPostfixOperator​(java.lang.String operatorString)
        Description copied from interface: OperatorDictionaryIfc
        Get the operator definition for a postfix operator name.
        Specified by:
        getPostfixOperator in interface OperatorDictionaryIfc
        Parameters:
        operatorString - The name of the operator.
        Returns:
        The operator definition or null if no operator was found.
      • getInfixOperator

        public OperatorIfc getInfixOperator​(java.lang.String operatorString)
        Description copied from interface: OperatorDictionaryIfc
        Get the operator definition for an infix operator name.
        Specified by:
        getInfixOperator in interface OperatorDictionaryIfc
        Parameters:
        operatorString - The name of the operator.
        Returns:
        The operator definition or null if no operator was found.