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 fileheaderFilePath- original path string of the header fileheaderPatterns- compiled regex patterns for header lineslineContents- 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 Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe field for theheaderFilePathrecord component.private final URIThe field for theheaderFileUrirecord component.The field for theheaderPatternsrecord component.The field for thelineContentsrecord component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateFromFile(String headerPath) Creates a HeaderFileMetadata instance by reading and processing the specified header file.private static PatterncreatePatternFromLine(String line) Creates a Pattern object from a line of text.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theheaderFilePathrecord component.Returns the value of theheaderFileUrirecord component.Returns an unmodifiable list of compiled header patterns.Returns an unmodifiable list of raw header line contents.final StringtoString()Returns a string representation of this record class.private static StringvalidateRegex(String input) Ensures that the given input string is a valid regular expression.
-
Field Details
-
headerFileUri
The field for theheaderFileUrirecord component. -
headerFilePath
The field for theheaderFilePathrecord component. -
headerPatterns
The field for theheaderPatternsrecord component. -
lineContents
The field for thelineContentsrecord component.
-
-
Constructor Details
-
HeaderFileMetadata
private HeaderFileMetadata(URI headerFileUri, String headerFilePath, List<Pattern> headerPatterns, List<String> lineContents) Creates an instance of aHeaderFileMetadatarecord class.- Parameters:
headerFileUri- the value for theheaderFileUrirecord componentheaderFilePath- the value for theheaderFilePathrecord componentheaderPatterns- the value for theheaderPatternsrecord componentlineContents- the value for thelineContentsrecord component
-
-
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
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
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
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. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
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 withObjects::equals(Object,Object). -
headerFileUri
Returns the value of theheaderFileUrirecord component.- Returns:
- the value of the
headerFileUrirecord component
-
headerFilePath
Returns the value of theheaderFilePathrecord component.- Returns:
- the value of the
headerFilePathrecord component
-