Interface ProfileLock

All Superinterfaces:
AutoCloseable

public interface ProfileLock extends 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 Details

    • getProfiles

      List<ConfigProfile> getProfiles()
      Gets all configuration profiles.
      Returns:
      a list of all profiles
    • createProfile

      ConfigProfile createProfile(String name, long id)
      Creates a new configuration profile.
      Parameters:
      name - the display name for the new profile
      id - the unique identifier for the new profile
      Returns:
      the newly created profile
    • findProfile

      ConfigProfile findProfile(String name)
      Finds a profile by name.
      Parameters:
      name - the profile name to search for
      Returns:
      the matching profile, or null if not found
    • findProfile

      ConfigProfile findProfile(long id)
      Finds a profile by ID.
      Parameters:
      id - the profile ID to search for
      Returns:
      the matching profile, or null if not found
    • findProfile

      ConfigProfile findProfile(Predicate<ConfigProfile> condition)
      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

      void renameProfile(ConfigProfile profile, String name)
      Renames a profile.
      Parameters:
      profile - the profile to rename
      name - 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.