Class OpenFileLock.FileLockHandle

java.lang.Object
cloud.opencode.base.io.lock.OpenFileLock.FileLockHandle
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
OpenFileLock

public static class OpenFileLock.FileLockHandle extends Object implements Closeable
File Lock Handle 文件锁句柄

AutoCloseable handle for file locks. Use with try-with-resources.

文件锁的 AutoCloseable 句柄,配合 try-with-resources 使用。

Since:
JDK 25, opencode-base-io V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • getPath

      public Path getPath()
      Get the locked file path 获取锁定的文件路径
      Returns:
      file path | 文件路径
    • isShared

      public boolean isShared()
      Check if this is a shared lock 检查是否为共享锁
      Returns:
      true if shared lock | 如果是共享锁返回 true
    • isValid

      public boolean isValid()
      Check if lock is still valid 检查锁是否仍然有效
      Returns:
      true if valid | 如果有效返回 true
    • getChannel

      public FileChannel getChannel()
      Get the underlying FileChannel 获取底层 FileChannel
      Returns:
      file channel | 文件通道
    • getLock

      public FileLock getLock()
      Get the underlying FileLock 获取底层 FileLock
      Returns:
      file lock | 文件锁
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • toString

      public String toString()
      Overrides:
      toString in class Object