Record Class ResourceEvent

java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.resource.ResourceEvent

public record ResourceEvent(ResourceEvent.Type type, Resource resource, long timestamp) extends Record
Resource Change Event - Represents a file system change event for a resource 资源变更事件 - 表示资源的文件系统变更事件

Immutable record capturing the type of change, the affected resource, and the timestamp.

不可变记录,包含变更类型、受影响的资源和时间戳。

Usage Examples | 使用示例:

ResourceEvent event = new ResourceEvent(
    ResourceEvent.Type.MODIFIED,
    new FileResource("/etc/config.yml"),
    System.currentTimeMillis()
);

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: Yes - 空值安全: 是
Since:
JDK 25, opencode-base-classloader V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Resource change event type 资源变更事件类型
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceEvent(ResourceEvent.Type type, Resource resource, long timestamp)
    Compact constructor with null validation 紧凑构造器,包含空值校验
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the resource record component.
    long
    Returns the value of the timestamp record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ResourceEvent

      public ResourceEvent(ResourceEvent.Type type, Resource resource, long timestamp)
      Compact constructor with null validation 紧凑构造器,包含空值校验
      Throws:
      NullPointerException - if type or resource is null | 如果 type 或 resource 为 null 则抛出
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public ResourceEvent.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • resource

      public Resource resource()
      Returns the value of the resource record component.
      Returns:
      the value of the resource record component
    • timestamp

      public long timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component