Package blog.softwaretester.properties
Class PropertyAggregator.Builder
- java.lang.Object
-
- blog.softwaretester.properties.PropertyAggregator.Builder
-
- Enclosing class:
- PropertyAggregator
public static final class PropertyAggregator.Builder extends Object
Builder used to create aPropertyAggregatorinstance.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyAggregatorbuild()Return the configured PropertyAggregator instance.PropertyAggregator.BuilderwithCustomPredicate(Predicate<? super Map.Entry<String,String>> predicate)Apply a custom filter to the final properties.PropertyAggregator.BuilderwithDefaultValues(Map<String,String> defaultValues)Apply a map of keys with their default values.PropertyAggregator.BuilderwithEnvironmentProperties()Add an environment property source to the queue.PropertyAggregator.BuilderwithFilteredKeys(List<String> keys)Apply a list of keys to filter the final properties by.PropertyAggregator.BuilderwithPropertiesFile(String propertiesFilePath)Add a property file source to the queue.PropertyAggregator.BuilderwithPropertiesFileInClassPath(String propertiesFilePath)Add a property file source inside the application classpath to the queue.PropertyAggregator.BuilderwithSystemProperties()Add a system property source to the queue.
-
-
-
Method Detail
-
withSystemProperties
public PropertyAggregator.Builder withSystemProperties()
Add a system property source to the queue. Each new property source added has a higher priority than the previous one.- Returns:
- The
PropertyAggregator.
-
withEnvironmentProperties
public PropertyAggregator.Builder withEnvironmentProperties()
Add an environment property source to the queue. Each new property source added has a higher priority than the previous one.- Returns:
- The
PropertyAggregator.
-
withPropertiesFile
public PropertyAggregator.Builder withPropertiesFile(String propertiesFilePath)
Add a property file source to the queue. This can be added multiple times with different property files.- Parameters:
propertiesFilePath- The path to the properties file.- Returns:
- The
PropertyAggregator.
-
withPropertiesFileInClassPath
public PropertyAggregator.Builder withPropertiesFileInClassPath(String propertiesFilePath)
Add a property file source inside the application classpath to the queue. This can be added multiple times with different property files.- Parameters:
propertiesFilePath- The path to the properties file in the application classpath.- Returns:
- The
PropertyAggregator.
-
withFilteredKeys
public PropertyAggregator.Builder withFilteredKeys(List<String> keys)
Apply a list of keys to filter the final properties by. All properties whose key does not match any entry will be removed.- Parameters:
keys- A list of property keys to filter by.- Returns:
- The
PropertyAggregator.
-
withCustomPredicate
public PropertyAggregator.Builder withCustomPredicate(Predicate<? super Map.Entry<String,String>> predicate)
Apply a custom filter to the final properties. All properties that do not match the filter will be removed.- Parameters:
predicate- The filter to apply to the properties.- Returns:
- The
PropertyAggregator.
-
withDefaultValues
public PropertyAggregator.Builder withDefaultValues(Map<String,String> defaultValues)
Apply a map of keys with their default values. If a property with a default value is not set by any property source, it is added with its default value.- Parameters:
defaultValues- A map containing property keys and their default values.- Returns:
- The
PropertyAggregator.
-
build
public PropertyAggregator build()
Return the configured PropertyAggregator instance.- Returns:
- The final
PropertyAggregator_
-
-