Interface PluginSettings


  • public interface PluginSettings
    The class provides methods for reading/writing plugin settings.

    It is implemented by emuStudio. Plugins obtain this object in the constructor.

    NOTE: Keys are case-sensitive.

    Keys which are put into settings must not start with EMUSTUDIO_PREFIX. This prefix is reserved for emuStudio settings and might be overridden by emuStudio. However, there are some emuStudio settings obtainable by plugins.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EMUSTUDIO_AUTO
      Setting key defining if emuStudio runs in "Auto" (non-interactive) mode.
      static java.lang.String EMUSTUDIO_NO_GUI
      Setting key defining if emuStudio runs in "No GUI" mode.
      static java.lang.String EMUSTUDIO_PREFIX
      EmuStudio key prefix.
      static PluginSettings UNAVAILABLE
      "Unavailable" instance of PluginSettings.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean contains​(java.lang.String key)
      Check if a key is present in settings.
      java.util.List<java.lang.String> getArray​(java.lang.String key)
      Get an array from settings.
      java.util.List<java.lang.String> getArray​(java.lang.String key, java.util.List<java.lang.String> defaultValue)
      Get an array from settings.
      java.util.Optional<java.lang.Boolean> getBoolean​(java.lang.String key)
      Get a boolean value from settings.
      boolean getBoolean​(java.lang.String key, boolean defaultValue)
      Get a boolean value from settings.
      java.util.Optional<java.lang.Double> getDouble​(java.lang.String key)
      Get a double value from settings.
      double getDouble​(java.lang.String key, double defaultValue)
      Get a double value from settings.
      java.util.Optional<java.lang.Integer> getInt​(java.lang.String key)
      Get an int value from settings.
      int getInt​(java.lang.String key, int defaultValue)
      Get an int value from settings.
      java.util.Optional<java.lang.Long> getLong​(java.lang.String key)
      Get a long value from settings.
      long getLong​(java.lang.String key, long defaultValue)
      Get a long value from settings.
      java.util.Optional<java.lang.String> getString​(java.lang.String key)
      Get a String value from settings.
      java.lang.String getString​(java.lang.String key, java.lang.String defaultValue)
      Get a String value from settings.
      void remove​(java.lang.String key)
      Remove key from settings if present.
      void setArray​(java.lang.String key, java.util.List<java.lang.String> array)
      Set an array to the settings.
      void setBoolean​(java.lang.String key, boolean value)
      Set a boolean value to the settings.
      void setDouble​(java.lang.String key, double value)
      Set a double value to the settings.
      void setInt​(java.lang.String key, int value)
      Set an int value to the settings.
      void setLong​(java.lang.String key, long value)
      Set a long value to the settings.
      void setString​(java.lang.String key, java.lang.String value)
      Set a String value to the settings.
    • Field Detail

      • EMUSTUDIO_PREFIX

        static final java.lang.String EMUSTUDIO_PREFIX
        EmuStudio key prefix.
        See Also:
        Constant Field Values
      • EMUSTUDIO_NO_GUI

        static final java.lang.String EMUSTUDIO_NO_GUI
        Setting key defining if emuStudio runs in "No GUI" mode.
        See Also:
        Constant Field Values
      • EMUSTUDIO_AUTO

        static final java.lang.String EMUSTUDIO_AUTO
        Setting key defining if emuStudio runs in "Auto" (non-interactive) mode.
        See Also:
        Constant Field Values
      • UNAVAILABLE

        static final PluginSettings UNAVAILABLE
        "Unavailable" instance of PluginSettings.

        It means that all methods return dummy or null values.

        The instance might be useful when creating plugin object without emuStudio (e.g. a plugin wants to support command-line interface).

    • Method Detail

      • contains

        boolean contains​(java.lang.String key)
        Check if a key is present in settings.
        Parameters:
        key - setting key
        Returns:
        true if key is present in settings
      • remove

        void remove​(java.lang.String key)
             throws CannotUpdateSettingException
        Remove key from settings if present.

        NOTE: If key does not exist already, nothing will happen.

        Parameters:
        key - settings key
        Throws:
        CannotUpdateSettingException - if the setting could not be removed
      • getString

        java.util.Optional<java.lang.String> getString​(java.lang.String key)
        Get a String value from settings.
        Parameters:
        key - settings key
        Returns:
        String value if present
      • getString

        java.lang.String getString​(java.lang.String key,
                                   java.lang.String defaultValue)
        Get a String value from settings.
        Parameters:
        key - settings key
        defaultValue - default value
        Returns:
        String value if present, or defaultValue if not
      • getBoolean

        java.util.Optional<java.lang.Boolean> getBoolean​(java.lang.String key)
        Get a boolean value from settings.
        Parameters:
        key - settings key
        Returns:
        boolean value if present
      • getBoolean

        boolean getBoolean​(java.lang.String key,
                           boolean defaultValue)
        Get a boolean value from settings.
        Parameters:
        key - settings key
        defaultValue - default value
        Returns:
        boolean value if present, or defaultValue if not
      • getInt

        java.util.Optional<java.lang.Integer> getInt​(java.lang.String key)
        Get an int value from settings.
        Parameters:
        key - settings key
        Returns:
        int value if present
      • getInt

        int getInt​(java.lang.String key,
                   int defaultValue)
        Get an int value from settings.
        Parameters:
        key - settings key
        defaultValue - default value
        Returns:
        int value if present, or defaultValue if not
      • getLong

        java.util.Optional<java.lang.Long> getLong​(java.lang.String key)
        Get a long value from settings.
        Parameters:
        key - settings key
        Returns:
        long value if present
      • getLong

        long getLong​(java.lang.String key,
                     long defaultValue)
        Get a long value from settings.
        Parameters:
        key - settings key
        defaultValue - default value
        Returns:
        long value if present, or defaultValue if not
      • getDouble

        java.util.Optional<java.lang.Double> getDouble​(java.lang.String key)
        Get a double value from settings.
        Parameters:
        key - settings key
        Returns:
        double value if present
      • getDouble

        double getDouble​(java.lang.String key,
                         double defaultValue)
        Get a double value from settings.
        Parameters:
        key - settings key
        defaultValue - default value
        Returns:
        double value if present, or defaultValue if not
      • getArray

        java.util.List<java.lang.String> getArray​(java.lang.String key)
        Get an array from settings.
        Parameters:
        key - settings key
        Returns:
        List of String values if the key is present; empty List otherwise
      • getArray

        java.util.List<java.lang.String> getArray​(java.lang.String key,
                                                  java.util.List<java.lang.String> defaultValue)
        Get an array from settings.
        Parameters:
        key - settings key
        defaultValue - default value
        Returns:
        List of String values if the key is present; default value otherwise