Class Settings


  • public class Settings
    extends java.lang.Object
    Maintains a set of key/value pairs. The values are stored in a flat file.
    • Constructor Summary

      Constructors 
      Constructor Description
      Settings​(@NotNull java.nio.file.Path file)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getBoolean​(@NotNull SettingsEntry<java.lang.Boolean> key)
      Returns the boolean associated with the specified key at a node or defaultValue if there is no association for this key.
      int getInt​(@NotNull SettingsEntry<java.lang.Integer> key)
      Returns the integer associated with the specified key at a node or defaultValue if there is no association for this key.
      long getLong​(@NotNull SettingsEntry<java.lang.Long> key)
      Returns the long associated with the specified key at a node or defaultValue if there is no association for this key.
      @NotNull java.lang.String getString​(@NotNull SettingsEntry<?> key)
      Returns the string associated with the specified key at a node, or defaultValue if there is no association for this key.
      void putBoolean​(@NotNull SettingsEntry<java.lang.Boolean> key, boolean value)
      Stores a key/value pair.
      void putInt​(@NotNull SettingsEntry<java.lang.Integer> key, int value)
      Stores a key/value pair.
      void putLong​(@NotNull SettingsEntry<java.lang.Long> key, long value)
      Stores a key/value pair.
      void putString​(@NotNull SettingsEntry<?> key, @NotNull java.lang.String value)
      Stores a key/value pair.
      void remove​(@NotNull java.lang.String key)
      Removes a key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Settings

        public Settings​(@NotNull
                        @NotNull java.nio.file.Path file)
        Creates a new instance.
        Parameters:
        file - the file for loading/saving values
    • Method Detail

      • getString

        @NotNull
        public @NotNull java.lang.String getString​(@NotNull
                                                   @NotNull SettingsEntry<?> key)
        Returns the string associated with the specified key at a node, or defaultValue if there is no association for this key.
        Parameters:
        key - the key to get the value for
        Returns:
        the value
      • getBoolean

        public boolean getBoolean​(@NotNull
                                  @NotNull SettingsEntry<java.lang.Boolean> key)
        Returns the boolean associated with the specified key at a node or defaultValue if there is no association for this key.
        Parameters:
        key - the key to get the value for
        Returns:
        the value
      • getInt

        public int getInt​(@NotNull
                          @NotNull SettingsEntry<java.lang.Integer> key)
        Returns the integer associated with the specified key at a node or defaultValue if there is no association for this key.
        Parameters:
        key - the key to get the value for
        Returns:
        the value
      • getLong

        public long getLong​(@NotNull
                            @NotNull SettingsEntry<java.lang.Long> key)
        Returns the long associated with the specified key at a node or defaultValue if there is no association for this key.
        Parameters:
        key - the key to get the value for
        Returns:
        the value
      • putString

        public void putString​(@NotNull
                              @NotNull SettingsEntry<?> key,
                              @NotNull
                              @NotNull java.lang.String value)
        Stores a key/value pair.
        Parameters:
        key - the key to store
        value - the value to store
      • putBoolean

        public void putBoolean​(@NotNull
                               @NotNull SettingsEntry<java.lang.Boolean> key,
                               boolean value)
        Stores a key/value pair.
        Parameters:
        key - the key to store
        value - the value to store
      • putInt

        public void putInt​(@NotNull
                           @NotNull SettingsEntry<java.lang.Integer> key,
                           int value)
        Stores a key/value pair.
        Parameters:
        key - the key to store
        value - the value to store
      • putLong

        public void putLong​(@NotNull
                            @NotNull SettingsEntry<java.lang.Long> key,
                            long value)
        Stores a key/value pair.
        Parameters:
        key - the key to store
        value - the value to store
      • remove

        public void remove​(@NotNull
                           @NotNull java.lang.String key)
        Removes a key. Does nothing if the key has no associated value.
        Parameters:
        key - the key to remove