Record Class ConfigSourceRoots

java.lang.Object
java.lang.Record
org.sonar.plugins.python.indexer.ConfigSourceRoots
Record Components:
configFile - the configuration file from which the source roots were extracted
relativeRoots - the relative source root paths defined in the config file

public record ConfigSourceRoots(File configFile, List<String> relativeRoots) extends Record
Represents source roots extracted from a build configuration file (pyproject.toml or setup.py).

This record associates relative source root paths with the configuration file they were extracted from, allowing proper resolution of absolute paths relative to the config file's location rather than the project base directory.

  • Constructor Details

    • ConfigSourceRoots

      public ConfigSourceRoots(File configFile, List<String> relativeRoots)
      Creates an instance of a ConfigSourceRoots record class.
      Parameters:
      configFile - the value for the configFile record component
      relativeRoots - the value for the relativeRoots record component
  • Method Details

    • toAbsolutePaths

      public List<String> toAbsolutePaths()
      Converts the relative source roots to absolute paths.

      Each relative path is resolved relative to the parent directory of the configuration file. For example, if the config file is at /project/app/pyproject.toml and a relative root is "src", the absolute path will be /project/app/src.

      Returns:
      list of absolute paths for the source roots
    • empty

      public static ConfigSourceRoots empty(File configFile)
      Creates a ConfigSourceRoots with an empty list of relative roots.
      Parameters:
      configFile - the configuration file
      Returns:
      a ConfigSourceRoots with no relative roots
    • 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.
    • configFile

      public File configFile()
      Returns the value of the configFile record component.
      Returns:
      the value of the configFile record component
    • relativeRoots

      public List<String> relativeRoots()
      Returns the value of the relativeRoots record component.
      Returns:
      the value of the relativeRoots record component