Package net.octyl.levelheadered.rewriter
Interface FileHeaderRewriter
- All Known Subinterfaces:
StandardFileHeaderRewriter
public interface FileHeaderRewriter
Represents a way to change the file header to a specific text.
All implementations should be Serializable or a valid @Nested
property value, as they will be used in task inputs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdetectLineEnding(String content) Detects the line ending used in the given content, from either LF or CRLF.@Nullable ModificationWriterrewriteHeader(String fileContent, String headerText) Rewrites the header of the given file content to the specified header text, if needed.
-
Method Details
-
detectLineEnding
Detects the line ending used in the given content, from either LF or CRLF. If multiple line endings are used, an error is thrown. If no line endings are found,System.lineSeparator()is returned.- Parameters:
content- the content to analyze- Returns:
- the detected line ending
- Throws:
IllegalArgumentException- if multiple line endings are detected
-
rewriteHeader
Rewrites the header of the given file content to the specified header text, if needed.- Parameters:
fileContent- the content of the fileheaderText- the header text to apply- Returns:
- a function that writes the modified content to an
Appendableif the content needs to be modified, ornullotherwise
-