Package net.storm.api.plugins.config
Interface ProfileLock
- All Superinterfaces:
AutoCloseable
Interface for thread-safe operations on configuration profiles.
ProfileLock provides exclusive access to profile operations, ensuring that
concurrent modifications don't corrupt the profile data. It implements
AutoCloseable to support try-with-resources usage.
Example usage:
try (ProfileLock lock = profileManager.lock()) {
ConfigProfile profile = lock.findProfile("My Profile");
if (profile == null) {
profile = lock.createProfile("My Profile", System.currentTimeMillis());
}
lock.dirty(); // Mark for saving
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncreateProfile(String name, long id) Creates a new configuration profile.voiddirty()Marks the profile data as dirty (modified).findProfile(long id) Finds a profile by ID.findProfile(String name) Finds a profile by name.findProfile(Predicate<ConfigProfile> condition) Finds a profile matching the given condition.Gets all configuration profiles.voidremoveProfile(long id) Removes a profile by ID.voidrenameProfile(ConfigProfile profile, String name) Renames a profile.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
getProfiles
List<ConfigProfile> getProfiles()Gets all configuration profiles.- Returns:
- a list of all profiles
-
createProfile
Creates a new configuration profile.- Parameters:
name- the display name for the new profileid- the unique identifier for the new profile- Returns:
- the newly created profile
-
findProfile
Finds a profile by name.- Parameters:
name- the profile name to search for- Returns:
- the matching profile, or null if not found
-
findProfile
Finds a profile by ID.- Parameters:
id- the profile ID to search for- Returns:
- the matching profile, or null if not found
-
findProfile
Finds a profile matching the given condition.- Parameters:
condition- the predicate to match profiles against- Returns:
- the first matching profile, or null if none match
-
removeProfile
void removeProfile(long id) Removes a profile by ID.- Parameters:
id- the ID of the profile to remove
-
renameProfile
Renames a profile.- Parameters:
profile- the profile to renamename- the new name
-
dirty
void dirty()Marks the profile data as dirty (modified).Call this after making changes that should be persisted. The actual save may occur asynchronously.
-