Interface LockedPath

All Superinterfaces:
AutoCloseable

public interface LockedPath extends AutoCloseable
A locked path.
Author:
poirigui
  • Method Details

    • getPath

      Path getPath()
      Retrieve the path being locked.
    • isValid

      boolean isValid()
      Indicate if the lock is valid.
    • isShared

      boolean isShared()
      Indicate if the lock is shared.
    • close

      void close()
      Release the lock.

      This does nothing if the lock is already closed or stolen.

      Specified by:
      close in interface AutoCloseable
    • closeAndGetPath

      @WillClose Path closeAndGetPath()
      Release the lock and obtain the underlying Path object.

      This does nothing if the lock is already closed or stolen.

    • toExclusive

      @WillClose LockedPath toExclusive()
      Convert this lock to an exclusive lock.

      This lock will be closed as a result.

      Throws:
      IllegalStateException - if this lock is already exclusive or no longer valid
    • toExclusive

      @WillClose LockedPath toExclusive(long timeout, TimeUnit timeUnit) throws InterruptedException, TimeoutException
      Try to convert this lock to an exclusive lock.

      This lock will be closed as a result.

      Throws:
      IllegalStateException - if this lock is already exclusive or no longer valid
      InterruptedException
      TimeoutException
    • toShared

      Convert this lock to a shared lock.

      This lock will be closed as a result.

      Throws:
      IllegalStateException - if this lock is already shared or no longer valid
    • steal

      Steal this lock.

      Once stolen, this lock will no-longer be released when closed.

      Throws:
      IllegalStateException - if this lock is already stolen or no longer valid
    • stealWithPath

      @WillClose LockedPath stealWithPath(Path path)
      Steal this lock with a different path. The lock will still be held on the original path, but will indicate a different path.
      Throws:
      IllegalStateException - if this lock is already stolen or no longer valid