Record Class MultiFileRegexpHeaderCheck.HeaderFileMetadata

java.lang.Object
java.lang.Record
com.puppycrawl.tools.checkstyle.checks.header.MultiFileRegexpHeaderCheck.HeaderFileMetadata
Record Components:
headerFileUri - URI of the header file
headerFilePath - original path string of the header file
headerPatterns - compiled regex patterns for header lines
lineContents - raw lines from the header file
Enclosing class:
MultiFileRegexpHeaderCheck

private static record MultiFileRegexpHeaderCheck.HeaderFileMetadata(URI headerFileUri, String headerFilePath, List<Pattern> headerPatterns, List<String> lineContents) extends Record
Metadata holder for a header file, storing its URI, compiled patterns, and line contents.
  • Field Details

  • Constructor Details

  • Method Details

    • createFromFile

      Creates a HeaderFileMetadata instance by reading and processing the specified header file.
      Parameters:
      headerPath - path to the header file
      Returns:
      HeaderFileMetadata instance
      Throws:
      IllegalArgumentException - if the header file is invalid or cannot be read
    • createPatternFromLine

      private static Pattern createPatternFromLine(String line)
      Creates a Pattern object from a line of text.
      Parameters:
      line - the line to create a pattern from
      Returns:
      the compiled Pattern
    • headerPatterns

      Returns an unmodifiable list of compiled header patterns.
      Returns:
      header patterns
    • lineContents

      Returns an unmodifiable list of raw header line contents.
      Returns:
      header lines
    • validateRegex

      private static String validateRegex(String input)
      Ensures that the given input string is a valid regular expression.

      This method validates that the input is a correctly formatted regex string and will throw a PatternSyntaxException if it's invalid.

      Parameters:
      input - the string to be treated as a regex pattern
      Returns:
      the validated regex pattern string
      Throws:
      IllegalArgumentException - if the pattern is not a valid regex
    • 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.
    • headerFileUri

      public URI headerFileUri()
      Returns the value of the headerFileUri record component.
      Returns:
      the value of the headerFileUri record component
    • headerFilePath

      Returns the value of the headerFilePath record component.
      Returns:
      the value of the headerFilePath record component