Class Settings

    • Method Detail

      • find

        public Optional<Setting<?>> find​(String identifier)
        Parameters:
        identifier - the identifier of the setting to find
        Returns:
        the setting with the identifier supplied, if present
      • find

        public <S extends Setting<?>> Optional<S> find​(S setting)
        This method is semantically equivalent to:

         find(setting.getIdentifier()).flatMap(s -> s.as(setting))
         
        Type Parameters:
        S - generic setting type
        Parameters:
        setting - a setting key
        Returns:
        the setting with the same setting key as the supplied setting, if present.
      • get

        public <E> E get​(Setting<E> defaultSetting)
        This method is semantically equivalent to:

         find(defaultSetting).orElse(defaultSetting).getValue()
         
        Type Parameters:
        E - generic setting type
        Parameters:
        defaultSetting - a default key for which to obtain a value set
        Returns:
        the value set for defaultSetting's key, if present. Otherwise, returns defaultSetting's value.
      • of

        public static Settings of​(Setting<?> s)
        Returns a singleton Settings object, containing only the supplied Setting.
        Parameters:
        s - one Setting
        Returns:
        a Settings object containing the supplied Setting.
      • of

        public static Settings of​(Setting<?>... settings)
        Parameters:
        settings - one or more Setting's
        Returns:
        a Settings object containing the supplied settings. For any two settings having the same key, the first will be overwritten by the second.
        Throws:
        IllegalArgumentException - if any two settings have the same identifier