Class PropertyStore
-
- All Implemented Interfaces:
public final class PropertyStoreProperty-storage core of ServerPackCreator: loads properties-files with blank-value filtering, offers typed accessors with define-if-absent-semantics, manages custom user-properties under a dedicated prefix, and saves the merged state back to every tracked file. Extracted from ApiProperties (refactor Phase 1b) so configuration-groups can share one storage-engine.
-
-
Field Summary
Fields Modifier and Type Field Description private final StringcustomPropertyPrefixprivate final Propertiesproperties
-
Constructor Summary
Constructors Constructor Description PropertyStore()
-
Method Summary
Modifier and Type Method Description final StringgetCustomPropertyPrefix()final PropertiesgetProperties()final UnitloadInto(File propertiesFile, Properties target)Loads the given properties-file into target, dropping blank values and remembering the file for later save-calls. final UnitloadOverrides(File overridesFile)Loads the given overrides-file directly into properties, replacing already-loaded values. final Stringacquire(String key, String defaultValue)Returns the value for key, defining it with defaultValue first when the key is absent or blank, thus guaranteeing subsequent calls find the key present. final Stringdefine(String key, String value)Sets key to value and returns the value for convenient chaining. final List<String>getList(String key, String defaultValue)Returns the comma-separated value of key as a list, dropping empty trailing entries; a value without separator yields a singleton-list. final UnitsetList(String key, List<String> values, String separator)Sets key to values joined by separator. final IntegergetInt(String key, Integer defaultValue)Returns the integer-value of key; an unparseable value resets the key to defaultValue and returns it. final StringsetInt(String key, Integer value)Sets the integer-property key to value. final List<File>getFileList(String key, String defaultValue, String filePrefix)Returns the entries of the comma-separated list in key as files, each prefixed with filePrefix. final BooleangetBool(String key, Boolean defaultValue)Returns the boolean-value of key; any value other than "true" (case-insensitive) is false. final StringsetBool(String key, Boolean value)Sets the boolean-property key to value. final StringstoreCustomProperty(String property, String value)Stores a user-defined property under the customPropertyPrefix to prevent clashes with ServerPackCreator's own keys, returning the stored value. final StringretrieveCustomProperty(String property)Retrieves a user-defined property stored under the customPropertyPrefix, or null when undefined. final List<File>trackedFiles()The files from which properties were loaded and to which save writes back. final UnitclearTrackedFiles()Forgets all tracked properties-files, so subsequent save-calls only write the always-written file. final Unitsave(File propertiesFile, File alwaysWrite, List<String> removeKeys)Saves the merged properties to propertiesFile and every tracked file, dropping removeKeys (legacy-keys) first. -
-
Method Detail
-
getCustomPropertyPrefix
final String getCustomPropertyPrefix()
-
getProperties
final Properties getProperties()
-
loadInto
final Unit loadInto(File propertiesFile, Properties target)
Loads the given properties-file into target, dropping blank values and remembering the file for later save-calls. A missing file is logged and skipped.
-
loadOverrides
final Unit loadOverrides(File overridesFile)
Loads the given overrides-file directly into properties, replacing already-loaded values. Every overridden key is logged; values of keys containing credentials are masked.
-
acquire
final String acquire(String key, String defaultValue)
Returns the value for key, defining it with defaultValue first when the key is absent or blank, thus guaranteeing subsequent calls find the key present.
-
getList
final List<String> getList(String key, String defaultValue)
Returns the comma-separated value of key as a list, dropping empty trailing entries; a value without separator yields a singleton-list. Absent keys are defined with defaultValue.
-
getInt
final Integer getInt(String key, Integer defaultValue)
Returns the integer-value of key; an unparseable value resets the key to defaultValue and returns it.
-
getFileList
final List<File> getFileList(String key, String defaultValue, String filePrefix)
Returns the entries of the comma-separated list in key as files, each prefixed with filePrefix. Absent keys are defined with defaultValue.
-
getBool
final Boolean getBool(String key, Boolean defaultValue)
Returns the boolean-value of key; any value other than "true" (case-insensitive) is false. Absent keys are defined with defaultValue.
-
storeCustomProperty
final String storeCustomProperty(String property, String value)
Stores a user-defined property under the customPropertyPrefix to prevent clashes with ServerPackCreator's own keys, returning the stored value.
-
retrieveCustomProperty
final String retrieveCustomProperty(String property)
Retrieves a user-defined property stored under the customPropertyPrefix, or null when undefined.
-
trackedFiles
final List<File> trackedFiles()
The files from which properties were loaded and to which save writes back.
-
clearTrackedFiles
final Unit clearTrackedFiles()
Forgets all tracked properties-files, so subsequent save-calls only write the always-written file.
-
save
final Unit save(File propertiesFile, File alwaysWrite, List<String> removeKeys)
Saves the merged properties to propertiesFile and every tracked file, dropping removeKeys (legacy-keys) first. Tracked files which no longer exist are skipped, except alwaysWrite, which is created when missing.
-
-
-
-