@@ -60,56 +60,56 @@ public static LicenseHeaderStep headerDelimiter(ThrowingEx.Supplier<String> head
60
60
final String delimiter ;
61
61
final String yearSeparator ;
62
62
final Supplier <YearMode > yearMode ;
63
- final @ Nullable String skipLinesPattern ;
63
+ final @ Nullable String skipLinesMatching ;
64
64
65
- private LicenseHeaderStep (@ Nullable String name , @ Nullable String contentPattern , ThrowingEx .Supplier <String > headerLazy , String delimiter , String yearSeparator , Supplier <YearMode > yearMode , @ Nullable String skipLinesPattern ) {
65
+ private LicenseHeaderStep (@ Nullable String name , @ Nullable String contentPattern , ThrowingEx .Supplier <String > headerLazy , String delimiter , String yearSeparator , Supplier <YearMode > yearMode , @ Nullable String skipLinesMatching ) {
66
66
this .name = sanitizeName (name );
67
67
this .contentPattern = sanitizePattern (contentPattern );
68
68
this .headerLazy = Objects .requireNonNull (headerLazy );
69
69
this .delimiter = Objects .requireNonNull (delimiter );
70
70
this .yearSeparator = Objects .requireNonNull (yearSeparator );
71
71
this .yearMode = Objects .requireNonNull (yearMode );
72
- this .skipLinesPattern = sanitizePattern (skipLinesPattern );
72
+ this .skipLinesMatching = sanitizePattern (skipLinesMatching );
73
73
}
74
74
75
75
public String getName () {
76
76
return name ;
77
77
}
78
78
79
79
public LicenseHeaderStep withName (String name ) {
80
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
80
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
81
81
}
82
82
83
83
public LicenseHeaderStep withContentPattern (String contentPattern ) {
84
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
84
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
85
85
}
86
86
87
87
public LicenseHeaderStep withHeaderString (String header ) {
88
88
return withHeaderLazy (() -> header );
89
89
}
90
90
91
91
public LicenseHeaderStep withHeaderLazy (ThrowingEx .Supplier <String > headerLazy ) {
92
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
92
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
93
93
}
94
94
95
95
public LicenseHeaderStep withDelimiter (String delimiter ) {
96
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
96
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
97
97
}
98
98
99
99
public LicenseHeaderStep withYearSeparator (String yearSeparator ) {
100
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
100
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
101
101
}
102
102
103
103
public LicenseHeaderStep withYearMode (YearMode yearMode ) {
104
104
return withYearModeLazy (() -> yearMode );
105
105
}
106
106
107
107
public LicenseHeaderStep withYearModeLazy (Supplier <YearMode > yearMode ) {
108
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
108
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
109
109
}
110
110
111
- public LicenseHeaderStep withSkipLinesPattern (String skipLinesPattern ) {
112
- return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesPattern );
111
+ public LicenseHeaderStep withSkipLinesMatching (String skipLinesMatching ) {
112
+ return new LicenseHeaderStep (name , contentPattern , headerLazy , delimiter , yearSeparator , yearMode , skipLinesMatching );
113
113
}
114
114
115
115
public FormatterStep build () {
@@ -118,7 +118,7 @@ public FormatterStep build() {
118
118
if (yearMode .get () == YearMode .SET_FROM_GIT ) {
119
119
formatterStep = FormatterStep .createNeverUpToDateLazy (name , () -> {
120
120
boolean updateYear = false ; // doesn't matter
121
- Runtime runtime = new Runtime (headerLazy .get (), delimiter , yearSeparator , updateYear , skipLinesPattern );
121
+ Runtime runtime = new Runtime (headerLazy .get (), delimiter , yearSeparator , updateYear , skipLinesMatching );
122
122
return FormatterFunc .needsFile (runtime ::setLicenseHeaderYearsFromGitHistory );
123
123
});
124
124
} else {
@@ -136,7 +136,7 @@ public FormatterStep build() {
136
136
default :
137
137
throw new IllegalStateException (yearMode .toString ());
138
138
}
139
- return new Runtime (headerLazy .get (), delimiter , yearSeparator , updateYear , skipLinesPattern );
139
+ return new Runtime (headerLazy .get (), delimiter , yearSeparator , updateYear , skipLinesMatching );
140
140
}, step -> step ::format );
141
141
}
142
142
@@ -201,7 +201,7 @@ private static class Runtime implements Serializable {
201
201
private static final long serialVersionUID = 1475199492829130965L ;
202
202
203
203
private final Pattern delimiterPattern ;
204
- private final @ Nullable Pattern skipLinesPattern ;
204
+ private final @ Nullable Pattern skipLinesMatching ;
205
205
private final String yearSepOrFull ;
206
206
private final @ Nullable String yearToday ;
207
207
private final @ Nullable String beforeYear ;
@@ -210,7 +210,7 @@ private static class Runtime implements Serializable {
210
210
private final boolean licenseHeaderWithRange ;
211
211
212
212
/** The license that we'd like enforced. */
213
- private Runtime (String licenseHeader , String delimiter , String yearSeparator , boolean updateYearWithLatest , @ Nullable String skipLinesPattern ) {
213
+ private Runtime (String licenseHeader , String delimiter , String yearSeparator , boolean updateYearWithLatest , @ Nullable String skipLinesMatching ) {
214
214
if (delimiter .contains ("\n " )) {
215
215
throw new IllegalArgumentException ("The delimiter must not contain any newlines." );
216
216
}
@@ -220,7 +220,7 @@ private Runtime(String licenseHeader, String delimiter, String yearSeparator, bo
220
220
licenseHeader = licenseHeader + "\n " ;
221
221
}
222
222
this .delimiterPattern = Pattern .compile ('^' + delimiter , Pattern .UNIX_LINES | Pattern .MULTILINE );
223
- this .skipLinesPattern = skipLinesPattern == null ? null : Pattern .compile (skipLinesPattern );
223
+ this .skipLinesMatching = skipLinesMatching == null ? null : Pattern .compile (skipLinesMatching );
224
224
225
225
Optional <String > yearToken = getYearToken (licenseHeader );
226
226
if (yearToken .isPresent ()) {
@@ -262,7 +262,7 @@ private static Optional<String> getYearToken(String licenseHeader) {
262
262
263
263
/** Formats the given string. */
264
264
private String format (String raw ) {
265
- if (skipLinesPattern == null ) {
265
+ if (skipLinesMatching == null ) {
266
266
return addOrUpdateLicenseHeader (raw );
267
267
} else {
268
268
String [] lines = raw .split ("\n " );
@@ -271,7 +271,7 @@ private String format(String raw) {
271
271
boolean lastMatched = true ;
272
272
for (String line : lines ) {
273
273
if (lastMatched ) {
274
- Matcher matcher = skipLinesPattern .matcher (line );
274
+ Matcher matcher = skipLinesMatching .matcher (line );
275
275
if (matcher .find ()) {
276
276
skippedLinesBuilder .append (line ).append ('\n' );
277
277
} else {
0 commit comments