Class TerminalProperties<T extends TextTerminal<T>>

  • Type Parameters:
    T - the type of the TextTerminal.

    public class TerminalProperties<T extends TextTerminal<T>>
    extends java.lang.Object
    A map of properties associated with a TextTerminal.
    • Constructor Detail

      • TerminalProperties

        public TerminalProperties​(T textTerminal)
    • Method Detail

      • remove

        public java.lang.Object remove​(java.lang.String key)
        Removes the property with the specified key.
        Parameters:
        key - the key whose associated value should be removed.
        Returns:
        the old value associated with the specified key.
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.lang.Object value)
        Sets the value associated with the specified key.
        Parameters:
        key - the key with which the specified value should be associated.
        value - the value to be associated with the specified key.
        Returns:
      • putAll

        public void putAll​(java.util.Map<java.lang.String,​? extends java.lang.Object> map)
      • getAllKeys

        public java.util.Set<java.lang.String> getAllKeys()
      • getMatchingKeys

        public java.util.Set<java.lang.String> getMatchingKeys​(java.lang.String regex)
      • getMatchingKeys

        public java.util.Set<java.lang.String> getMatchingKeys​(java.util.function.Predicate<java.lang.String> keyFilter)
      • getString

        public java.lang.String getString​(java.lang.String key)
        Returns:
        the value associated with the specified key.
      • getString

        public java.lang.String getString​(java.lang.String key,
                                          java.lang.String defaultValue)
        Gets the String value of the property with the specified key.
        Parameters:
        key - the key whose associated value should be retrieved.
        defaultValue - the value to be returned if no value is associated with the specified key or the associated value is null or empty.
        Returns:
        the string value of the property with the specified key.
      • getInt

        public int getInt​(java.lang.String key,
                          int defaultValue)
        Gets the int value of the property with the specified key.
        Parameters:
        key - the key whose associated value should be retrieved.
        defaultValue - the value to be returned if no value is associated with the specified key or the string representation of the value cannot be converted to int.
        Returns:
        the int value of the property with the specified key.
      • getLong

        public long getLong​(java.lang.String key,
                            long defaultValue)
        Gets the long value of the property with the specified key.
        Parameters:
        key - the key whose associated value should be retrieved.
        defaultValue - the value to be returned if no value is associated with the specified key or the string representation of the value cannot be converted to long.
        Returns:
        the long value of the property with the specified key.
      • getDouble

        public double getDouble​(java.lang.String key,
                                double defaultValue)
        Gets the double value of the property with the specified key.
        Parameters:
        key - the key whose associated value should be retrieved.
        defaultValue - the value to be returned if no value is associated with the specified key or the string representation of the value cannot be converted to double.
        Returns:
        the double value of the property with the specified key.
      • getBoolean

        public boolean getBoolean​(java.lang.String key,
                                  boolean defaultValue)
        Gets the boolean value of the property with the specified key.
        Parameters:
        key - the key whose associated value should be retrieved.
        defaultValue - the value to be returned if no value is associated with the specified key.
        Returns:
        the boolean value of the property with the specified key.
      • removeListener

        public boolean removeListener​(TerminalProperties.ExtendedChangeListener<T> listener)
        Removes the listener passed as argument.
        Parameters:
        listener - the listener to be added.
        Returns:
        true, if the listener has been found and removed.
      • addStringListener

        public void addStringListener​(java.lang.String key,
                                      java.lang.String defaultValue,
                                      TerminalProperties.StringChangeListener<T> listener)
        Convenience method that adds a listener for the String property with the specified key.
        Parameters:
        key - the key of the property for which the listener is added.
        defaultValue - the value to be used if the new value is null.
        listener - the listener to be added.
      • addIntListener

        public void addIntListener​(java.lang.String key,
                                   int defaultValue,
                                   TerminalProperties.IntChangeListener<T> listener)
        Convenience method that adds a listener for the int property with the specified key.
        Parameters:
        key - the key of the property for which the listener is added.
        defaultValue - the value to be used if the new value cannot be converted to an int.
        listener - the listener to be added.
      • addLongListener

        public void addLongListener​(java.lang.String key,
                                    long defaultValue,
                                    TerminalProperties.LongChangeListener<T> listener)
        Convenience method that adds a listener for the long property with the specified key.
        Parameters:
        key - the key of the property for which the listener is added.
        defaultValue - the value to be used if the new value cannot be converted to a long.
        listener - the listener to be added.
      • addDoubleListener

        public void addDoubleListener​(java.lang.String key,
                                      double defaultValue,
                                      TerminalProperties.DoubleChangeListener<T> listener)
        Convenience method that adds a listener for the double property with the specified key.
        Parameters:
        key - the key of the property for which the listener is added.
        defaultValue - the value to be used if the new value cannot be converted to a double.
        listener - the listener to be added.
      • addBooleanListener

        public void addBooleanListener​(java.lang.String key,
                                       boolean defaultValue,
                                       TerminalProperties.BooleanChangeListener<T> listener)
        Convenience method that adds a listener for the boolean property with the specified key.
        Parameters:
        key - the key of the property for which the listener is added.
        defaultValue - the value to be used if the new value is null.
        listener - the listener to be added.
      • setPromptColor

        public void setPromptColor​(java.lang.String color)
        Convenience method that associates the specified color with the key "prompt.color"
      • setPromptColor

        public void setPromptColor​(java.awt.Color color)
        Convenience method that associates the hex representation of the specified color with the key "prompt.color"
      • setPromptBackgroundColor

        public void setPromptBackgroundColor​(java.lang.String bgcolor)
        Convenience method that associates the specified bgcolor with the key "prompt.bgcolor"
      • setPromptBackgroundColor

        public void setPromptBackgroundColor​(java.awt.Color bgcolor)
        Convenience method that associates the hex representation of the specified bgcolor with the key "prompt.bgcolor"
      • setPromptBold

        public void setPromptBold​(boolean bold)
        Convenience method that associates the boolean value bold with the key "prompt.bold"
      • setPromptItalic

        public void setPromptItalic​(boolean italic)
        Convenience method that associates the boolean value italic with the key "prompt.italic"
      • setPromptUnderline

        public void setPromptUnderline​(boolean underline)
        Convenience method that associates the boolean value underline with the key "prompt.underline"
      • setInputColor

        public void setInputColor​(java.lang.String color)
        Convenience method that associates the specified color with the key "input.color"
      • setInputColor

        public void setInputColor​(java.awt.Color color)
        Convenience method that associates the hex representation of the specified color with the key "input.color"
      • setInputBackgroundColor

        public void setInputBackgroundColor​(java.lang.String bgcolor)
        Convenience method that associates the specified bgcolor with the key "input.bgcolor"
      • setInputBackgroundColor

        public void setInputBackgroundColor​(java.awt.Color bgcolor)
        Convenience method that associates the hex representation of the specified bgcolor with the key "input.bgcolor"
      • setInputBold

        public void setInputBold​(boolean bold)
        Convenience method that associates the boolean value bold with the key "input.bold"
      • setInputItalic

        public void setInputItalic​(boolean italic)
        Convenience method that associates the boolean value italic with the key "input.italic"
      • setInputUnderline

        public void setInputUnderline​(boolean underline)
        Convenience method that associates the boolean value underline with the key "input.underline"
      • setPaneBackgroundColor

        public void setPaneBackgroundColor​(java.lang.String bgcolor)
        Convenience method that associates the specified bgcolor with the key "pane.bgcolor"
      • setPaneBackgroundColor

        public void setPaneBackgroundColor​(java.awt.Color bgcolor)
        Convenience method that associates the hex representation of the specified bgcolor with the key "pane.bgcolor"
      • setPaneWidth

        public void setPaneWidth​(int width)
        Convenience method that associates the specified width with the key "pane.width"
      • setPaneHeight

        public void setPaneHeight​(int height)
        Convenience method that associates the specified height with the key "pane.height"
      • setPaneDimension

        public void setPaneDimension​(int width,
                                     int height)
        Convenience method that associates the specified width and height with the keys "pane.width" and "pane.height"