Class ApplicationProperties
java.lang.Object
io.fluxzero.sdk.configuration.ApplicationProperties
Central utility for resolving configuration properties within a Fluxzero application.
This class delegates to a layered PropertySource, typically obtained from the active
Fluxzero instance. If no context-bound property source is present, it falls
back to a DecryptingPropertySource that wraps the default layered DefaultPropertySource.
Property sources are accessed in a prioritized order:
EnvironmentVariablesSource– highest precedenceSystemPropertiesSourceApplicationEnvironmentPropertiesSource– e.g. application-dev.propertiesApplicationPropertiesSource– fallback base configuration from application.properties
Property resolution supports typed access, default values, encryption, and template substitution.
Common usage:
String token = ApplicationProperties.getProperty("FLUXZERO_API_TOKEN");
boolean featureEnabled = ApplicationProperties.getBooleanProperty("my.feature.enabled", true);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsProperty(String name) Returnstrueif a property with the given name exists.static StringdecryptValue(String encryptedValue) Decrypts the given encrypted value using the configuredEncryptionstrategy.static StringencryptValue(String value) Encrypts the given value using the configuredEncryptionstrategy.static booleangetBooleanProperty(String name) Resolves a boolean property by key, returningfalseif not present.static booleangetBooleanProperty(String name, boolean defaultValue) Resolves a boolean property by key, returning a default if the property is not present.static EncryptionReturns the currently activeEncryptioninstance.static StringgetFirstAvailableProperty(String... propertyNames) Returns anOptionalcontaining the first non-null property value among the provided property names, if any exist.static IntegergetIntegerProperty(String name) Resolves an integer property by key, ornullif not found.static IntegergetIntegerProperty(String name, Integer defaultValue) Resolves an integer property by key, or returns the given default value if not found.static StringgetProperty(String name) Returns the raw string property for the given key, ornullif not found.static StringgetProperty(String name, String defaultValue) Returns the string property value for the given key, or the specified default if not found.static <T> TmapProperty(String name, Function<String, T> mapper) Maps a property value identified by its name to a desired type using the provided mapping function.static <T> TmapProperty(String name, Function<String, T> mapper, Supplier<T> defaultValueSupplier) Maps a property value identified by its name to a desired type using the provided mapping function.static StringrequireProperty(String name) Returns the string property for the given key, throwing anIllegalStateExceptionif not found.static StringsubstituteProperties(String template) Substitutes placeholders in the given template using current property values.static PropertiessubstituteProperties(Properties properties) Substitutes placeholders in the properties using current property values.
-
Constructor Details
-
ApplicationProperties
public ApplicationProperties()
-
-
Method Details
-
getProperty
-
mapProperty
-
mapProperty
public static <T> T mapProperty(String name, Function<String, T> mapper, Supplier<T> defaultValueSupplier) Maps a property value identified by its name to a desired type using the provided mapping function. If the property is not found, the method returns a default value supplied by the given supplier. -
getFirstAvailableProperty
-
getBooleanProperty
Resolves a boolean property by key, returningfalseif not present.Accepts case-insensitive "true" as
true, otherwise returnsfalse. -
getBooleanProperty
Resolves a boolean property by key, returning a default if the property is not present. -
getIntegerProperty
Resolves an integer property by key, ornullif not found.- Throws:
NumberFormatException- if the property value is not a valid integer
-
getIntegerProperty
Resolves an integer property by key, or returns the given default value if not found.- Throws:
NumberFormatException- if the property value is not a valid integer
-
getProperty
-
requireProperty
Returns the string property for the given key, throwing anIllegalStateExceptionif not found. -
containsProperty
Returnstrueif a property with the given name exists. -
substituteProperties
-
substituteProperties
Substitutes placeholders in the properties using current property values.Placeholders use the syntax
${propertyName}. -
getEncryption
Returns the currently activeEncryptioninstance.By default, wraps the encryption from the current
PropertySource. -
encryptValue
Encrypts the given value using the configuredEncryptionstrategy. -
decryptValue
Decrypts the given encrypted value using the configuredEncryptionstrategy.Returns the original value if decryption is not applicable.
-