Record Class ConflictReport

java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.conflict.ConflictReport
Record Components:
conflicts - className to list of JarInfo where it appears (only entries with 2+ JARs) 类名到其出现的 JarInfo 列表的映射(仅包含 2+ 个 JAR 的条目)
totalConflicts - the total number of conflicting class entries | 冲突类条目的总数
totalClassesScanned - the total number of classes scanned | 扫描的类总数

public record ConflictReport(Map<String, List<JarInfo>> conflicts, int totalConflicts, int totalClassesScanned) extends Record
Immutable report of JAR class conflicts JAR 类冲突的不可变报告

Contains a mapping of fully-qualified class names to the list of JAR files in which they appear. Only classes found in two or more JARs are included.

包含完全限定类名到其出现的 JAR 文件列表的映射。仅包含在两个或多个 JAR 中发现的类。

Features | 主要功能:

  • Deep defensive copy on construction - 构造时深度防御性复制
  • Filter conflicts by JAR path - 按 JAR 路径过滤冲突
  • Human-readable summary generation - 生成人类可读摘要
  • Immutable and thread-safe - 不可变且线程安全

Usage Examples | 使用示例:

ConflictReport report = JarConflictDetector.detect(jar1, jar2);
if (report.hasConflicts()) {
    System.out.println(report.summary());
    Set<String> classes = report.conflictingClasses();
}

Security | 安全性:

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

    • ConflictReport

      public ConflictReport(Map<String, List<JarInfo>> conflicts, int totalConflicts, int totalClassesScanned)
      Creates a new ConflictReport with deep defensive copy 创建新的 ConflictReport 并进行深度防御性复制
      Parameters:
      conflicts - className to list of JarInfo | 类名到 JarInfo 列表
      totalConflicts - total conflict count | 冲突总数
      totalClassesScanned - total classes scanned | 扫描类总数
  • Method Details

    • hasConflicts

      public boolean hasConflicts()
      Check if any conflicts were detected 检查是否检测到冲突
      Returns:
      true if conflicts exist | 存在冲突返回 true
    • conflictingClasses

      public Set<String> conflictingClasses()
      Get the set of all conflicting class names 获取所有冲突类名的集合
      Returns:
      unmodifiable set of conflicting class names | 冲突类名的不可修改集合
    • getConflictsForJar

      public Map<String, List<JarInfo>> getConflictsForJar(Path jarPath)
      Get conflicts involving a specific JAR file 获取涉及特定 JAR 文件的冲突
      Parameters:
      jarPath - the JAR path to filter by | 要过滤的 JAR 路径
      Returns:
      filtered conflict map | 过滤后的冲突映射
    • summary

      public String summary()
      Generate a human-readable summary of the conflict report 生成冲突报告的人类可读摘要
      Returns:
      summary string | 摘要字符串
    • 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.
    • conflicts

      public Map<String, List<JarInfo>> conflicts()
      Returns the value of the conflicts record component.
      Returns:
      the value of the conflicts record component
    • totalConflicts

      public int totalConflicts()
      Returns the value of the totalConflicts record component.
      Returns:
      the value of the totalConflicts record component
    • totalClassesScanned

      public int totalClassesScanned()
      Returns the value of the totalClassesScanned record component.
      Returns:
      the value of the totalClassesScanned record component