Class DefaultConfiguration

  • All Implemented Interfaces:
    Configuration
    Direct Known Subclasses:
    DefaultModifiableConfiguration

    public class DefaultConfiguration
    extends Object
    implements Configuration
    Default implementation of Configuration. The default property values are read from the /default-configuration.properties properties file in classpath.
    Author:
    Michele Mostarda (michele.mostarda@gmail.com)
    • Constructor Detail

      • DefaultConfiguration

        protected DefaultConfiguration​(Properties properties)
    • Method Detail

      • singleton

        public static DefaultConfiguration singleton()
        Returns:
        the singleton configuration instance. Such instance is unmodifiable.
      • copy

        public static ModifiableConfiguration copy()
        Returns:
        a copy of the singleton instance. such instance is modifiable.
      • getProperties

        public String[] getProperties()
        Description copied from interface: Configuration
        Returns all the defined configuration properties.
        Specified by:
        getProperties in interface Configuration
        Returns:
        list of defined properties.
      • defineProperty

        public boolean defineProperty​(String propertyName)
        Description copied from interface: Configuration
        Checks whether a property is defined or not in configuration.
        Specified by:
        defineProperty in interface Configuration
        Parameters:
        propertyName - name of property to check.
        Returns:
        true if defined, false otherwise.
      • getProperty

        public String getProperty​(String propertyName,
                                  String defaultValue)
        Description copied from interface: Configuration
        Returns the value of a specified property, of the default value if property is not defined.
        Specified by:
        getProperty in interface Configuration
        Parameters:
        propertyName - name of property
        defaultValue - default value if not found.
        Returns:
        the value associated to propertyName.
      • getPropertyOrFail

        public String getPropertyOrFail​(String propertyName)
        Description copied from interface: Configuration
        Returns the value of the specified propertyName or raises an exception if propertyName is not defined.
        Specified by:
        getPropertyOrFail in interface Configuration
        Parameters:
        propertyName - name of property to be returned.
        Returns:
        property value.
      • getPropertyIntOrFail

        public int getPropertyIntOrFail​(String propertyName)
        Description copied from interface: Configuration
        Returns the Integer value of the specified propertyName or raises an exception if propertyName is not defined.
        Specified by:
        getPropertyIntOrFail in interface Configuration
        Parameters:
        propertyName - name of property to be returned.
        Returns:
        property value.
      • getFlagProperty

        public boolean getFlagProperty​(String propertyName)
        Description copied from interface: Configuration
        Returns the value of a flag property. Such properties can assume only two values:
        • on if flag is active (true is returned).
        • off if flag is inactive (false is returned).
        Specified by:
        getFlagProperty in interface Configuration
        Parameters:
        propertyName - name of property flag.
        Returns:
        true for on, false for off.
      • getConfigurationDump

        public String getConfigurationDump()
        Description copied from interface: Configuration
        Returns a human readable string containing the configuration dump.
        Specified by:
        getConfigurationDump in interface Configuration
        Returns:
        a string describing the configuration options.