Record Class JarInfo

java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.conflict.JarInfo
Record Components:
path - the absolute path to the JAR file | JAR 文件的绝对路径
version - the version from MANIFEST.MF, or null if not present | MANIFEST.MF 中的版本,不存在则为 null
name - the file name of the JAR | JAR 的文件名

public record JarInfo(Path path, String version, String name) extends Record
Immutable information about a JAR file JAR 文件的不可变信息

Captures the path, version, and name of a JAR file for use in conflict detection. Version is extracted from MANIFEST.MF (Implementation-Version or Bundle-Version); it may be null if not present.

捕获 JAR 文件的路径、版本和名称,用于冲突检测。版本从 MANIFEST.MF (Implementation-VersionBundle-Version) 提取;如果不存在则为 null

Features | 主要功能:

  • Immutable record - 不可变记录
  • Version extraction from MANIFEST.MF - 从 MANIFEST.MF 提取版本
  • Null-safe version field - 版本字段空值安全

Usage Examples | 使用示例:

JarInfo info = new JarInfo(Path.of("/libs/guava-31.jar"), "31.1-jre", "guava-31.jar");
System.out.println(info.name());    // "guava-31.jar"
System.out.println(info.version()); // "31.1-jre"

Security | 安全性:

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

    Constructors
    Constructor
    Description
    JarInfo(Path path, String version, String name)
    Creates a new JarInfo instance with validation 创建新的 JarInfo 实例并进行验证
  • 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 name record component.
    Returns the value of the path record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the version record component.

    Methods inherited from class Object

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

    • JarInfo

      public JarInfo(Path path, String version, String name)
      Creates a new JarInfo instance with validation 创建新的 JarInfo 实例并进行验证
      Parameters:
      path - the absolute path to the JAR file | JAR 文件的绝对路径
      version - the version from MANIFEST.MF, or null | MANIFEST.MF 中的版本,或 null
      name - the file name of the JAR | JAR 的文件名
  • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • path

      public Path path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component