Class Configuration
java.lang.Object
br.net.dd.netherwingcore.common.configuration.Configuration
The Configuration class represents a structure for managing configuration data.
It organizes the data into sections and items, supporting the retrieval of specific
configuration values by keys.
This class is designed to encapsulate a configuration's metadata such as a description and a service name, while also storing the configuration's hierarchical structure in sections and groups.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty Configuration object with default values: - an empty description - an empty service name - an empty list of sections.Configuration(Description description, String serviceName) Constructs a Configuration object with the specified description and service name, initializing the sections list as empty. -
Method Summary
Modifier and TypeMethodDescriptionaddSection(Section section) Adds a new section to the configuration.Retrieves an Item from the configuration that matches the specified key.Retrieves an integer value from the configuration based on the given key.Retrieves a string value from the configuration based on the given key.Gets the description of the configuration.Gets the list of sections in the configuration.Gets the name of the service associated with the configuration.
-
Constructor Details
-
Configuration
public Configuration()Constructs an empty Configuration object with default values: - an empty description - an empty service name - an empty list of sections. -
Configuration
Constructs a Configuration object with the specified description and service name, initializing the sections list as empty.- Parameters:
description- A Description object representing the configuration description.serviceName- A String representing the service name associated with the configuration.
-
-
Method Details
-
addSection
Adds a new section to the configuration.- Parameters:
section- A Section object to be added.- Returns:
- The Configuration object to allow method chaining.
-
get
-
get
Retrieves an integer value from the configuration based on the given key. Returns a default value if the item is not found or if the type does not match.- Parameters:
key- A String representing the key of the desired value.defaultValue- The default integer value to return if the key is not found.- Returns:
- The integer value associated with the key, or the default value if not found.
-
get
Retrieves a string value from the configuration based on the given key. Returns a default value if the item is not found or if the type does not match.- Parameters:
key- A String representing the key of the desired value.defaultValue- The default string value to return if the key is not found.- Returns:
- The string value associated with the key, or the default value if not found.
-
getDescription
Gets the description of the configuration.- Returns:
- A Description object containing the configuration description.
-
getServiceName
Gets the name of the service associated with the configuration.- Returns:
- A String representing the service name.
-
getSections
-