Interface PreferencesHandler


  • public interface PreferencesHandler
    Author:
    Fabrizio Giudici
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String __BASE_NAME  
      static java.util.concurrent.atomic.AtomicReference<PreferencesHandler> __INSTANCE  
      static it.tidalwave.util.Key<java.lang.Boolean> KEY_FULL_SCREEN
      Whether the application should start at full screen.
      static it.tidalwave.util.Key<java.lang.Double> KEY_INITIAL_SIZE
      A property representing the initial main window size as a percentual of the screen size.
      static java.lang.String PROP_APP_NAME  
    • Field Detail

      • PROP_APP_NAME

        static final java.lang.String PROP_APP_NAME
      • __INSTANCE

        static final java.util.concurrent.atomic.AtomicReference<PreferencesHandler> __INSTANCE
      • KEY_INITIAL_SIZE

        static final it.tidalwave.util.Key<java.lang.Double> KEY_INITIAL_SIZE
        A property representing the initial main window size as a percentual of the screen size.
      • KEY_FULL_SCREEN

        static final it.tidalwave.util.Key<java.lang.Boolean> KEY_FULL_SCREEN
        Whether the application should start at full screen.
    • Method Detail

      • getAppFolder

        @Nonnull
        java.nio.file.Path getAppFolder()
      • getLogFolder

        @Nonnull
        java.nio.file.Path getLogFolder()
      • setAppName

        static void setAppName​(@Nonnull
                               java.lang.String name)
        Sets the application name. This method must be called at boot from the main method before doing anything else.
        Parameters:
        name - the property name
      • getProperty

        @Nonnull
        <T> java.util.Optional<T> getProperty​(@Nonnull
                                              it.tidalwave.util.Key<T> name)
        Gets a property.
        Type Parameters:
        T - the property type
        Parameters:
        name - the property name
        Returns:
        the property value
      • setProperty

        <T> void setProperty​(@Nonnull
                             it.tidalwave.util.Key<T> name,
                             @Nonnull
                             T value)
        Sets a property, overriding the current value.
        Type Parameters:
        T - the property type
        Parameters:
        name - the property name
        value - the property value
      • setDefaultProperty

        <T> void setDefaultProperty​(@Nonnull
                                    it.tidalwave.util.Key<T> name,
                                    @Nonnull
                                    T value)
        Sets a property, unless it has been already set.
        Type Parameters:
        T - the property type
        Parameters:
        name - the property name
        value - the property value
      • getInstance

        @Nonnull
        static PreferencesHandler getInstance()
        main() probably needs it and dI has not booted yet, so this class can be accessed also by this factory method. Note that Spring instantiates the bean by calling this method, so we really have a singleton.