Skip to content

Commit c24d934

Browse files
committed
refactoring
1 parent a64b672 commit c24d934

21 files changed

Lines changed: 57 additions & 56 deletions

jcp-tests/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<packaging>pom</packaging>
99

1010
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1112
<jcp.test.version>7.0.3-SNAPSHOT</jcp.test.version>
1213
<junit.version>5.4.2</junit.version>
1314
<maven.compiler.source>1.8</maven.compiler.source>

jcp/src/main/java/com/igormaznitsa/jcp/ant/PreprocessTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public Value getVariable(final String varName, final PreprocessorContext context
264264
final Value result = this.antVariables.get(varName);
265265

266266
if (result == null) {
267-
throw context.makeException("Request for unsupported Ant property \'" + varName + '\'', null);
267+
throw context.makeException("Request for unsupported Ant property '" + varName + '\'', null);
268268
}
269269
return result;
270270
}
@@ -273,7 +273,7 @@ public Value getVariable(final String varName, final PreprocessorContext context
273273
public void setVariable(final String varName, final Value value,
274274
final PreprocessorContext context) {
275275
throw context.makeException(
276-
"Request to change ANT property \'" + varName + "\'. NB! ANT properties are read only!",
276+
"Request to change ANT property '" + varName + "'. NB! ANT properties are read only!",
277277
null);
278278
}
279279

jcp/src/main/java/com/igormaznitsa/jcp/cmdline/ExcludedFileExtensionsHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public class ExcludedFileExtensionsHandler implements CommandLineHandler {
4040
public String getDescription() {
4141
return
4242
"comma separated file extensions (case insensetive) to be excluded from preprocess and copy (by default " +
43-
PreprocessorContext.DEFAULT_EXCLUDED_EXTENSIONS.stream()
44-
.collect(Collectors.joining(",")) + ')';
43+
String.join(",", PreprocessorContext.DEFAULT_EXCLUDED_EXTENSIONS) + ')';
4544
}
4645

4746
@Override

jcp/src/main/java/com/igormaznitsa/jcp/cmdline/FileExtensionsHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public class FileExtensionsHandler implements CommandLineHandler {
3939
@Override
4040
public String getDescription() {
4141
return "comma separated list of allowed extensions (case insensitive) (by default " +
42-
PreprocessorContext.DEFAULT_PROCESSING_EXTENSIONS.stream()
43-
.collect(Collectors.joining(",")) + ')';
42+
String.join(",", PreprocessorContext.DEFAULT_PROCESSING_EXTENSIONS) + ')';
4443
}
4544

4645
@Override

jcp/src/main/java/com/igormaznitsa/jcp/cmdline/GlobalVariableDefiningFileHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public boolean processCommandLineKey(final String key, final PreprocessorContext
5959

6060
if (context.isVerbose()) {
6161
context.logForVerbose(
62-
"Global parameter file defined through expression \'" + stringRest + '\'');
62+
"Global parameter file defined through expression '" + stringRest + '\'');
6363
}
6464

6565
final Value resultValue = Expression.evalExpression(stringRest, context);
@@ -72,14 +72,14 @@ public boolean processCommandLineKey(final String key, final PreprocessorContext
7272

7373
if (context.isVerbose()) {
7474
context.logForVerbose(
75-
"Reading global definition file [" + PreprocessorUtils.getFilePath(file) + "] \'" +
75+
"Reading global definition file [" + PreprocessorUtils.getFilePath(file) + "] '" +
7676
stringRest + '\'');
7777
}
7878
if (file.isFile()) {
7979
context.registerConfigFile(file);
8080
} else {
8181
throw context.makeException(
82-
"Can't find the global definition file \'" + PreprocessorUtils.getFilePath(file) + '\'',
82+
"Can't find the global definition file '" + PreprocessorUtils.getFilePath(file) + '\'',
8383
null);
8484
}
8585

jcp/src/main/java/com/igormaznitsa/jcp/cmdline/SourceDirectoryHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public boolean processCommandLineKey(final String key, final PreprocessorContext
5555
final String tail = PreprocessorUtils.extractTrimmedTail(ARG_NAME, key);
5656
if (!tail.isEmpty()) {
5757
context.setSources(
58-
Arrays.asList(extractTail(ARG_NAME, key).split(Pattern.quote(File.pathSeparator)))
59-
.stream().map(String::trim).collect(Collectors.toList()));
58+
Arrays.stream(extractTail(ARG_NAME, key).split(Pattern.quote(File.pathSeparator)))
59+
.map(String::trim).collect(Collectors.toList()));
6060
result = true;
6161
}
6262
}

jcp/src/main/java/com/igormaznitsa/jcp/context/JCPSpecialVariableProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void setVariable(final String varName, final Value value,
190190
case VAR_TIME:
191191
case VAR_TIMESTAMP:
192192
case VAR_DATE: {
193-
final String text = "The variable \'" + varName + "\' can't be set directly";
193+
final String text = "The variable '" + varName + "' can't be set directly";
194194
throw context.makeException(text, null);
195195
}
196196
default: {

jcp/src/main/java/com/igormaznitsa/jcp/context/PreprocessorContext.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public PreprocessorContext removeLocalVariable(final String name) {
531531
}
532532

533533
if (isVerbose()) {
534-
logForVerbose("Removing local variable '" + normalized + "\'");
534+
logForVerbose("Removing local variable '" + normalized + "'");
535535
}
536536
localVarTable.remove(normalized);
537537
return this;
@@ -559,7 +559,7 @@ public PreprocessorContext removeGlobalVariable(final String name) {
559559
}
560560

561561
if (isVerbose()) {
562-
logForVerbose("Removing global variable '" + normalized + "\'");
562+
logForVerbose("Removing global variable '" + normalized + "'");
563563
}
564564

565565
globalVarTable.remove(normalized);
@@ -794,11 +794,11 @@ public File findFileInSources(final String path) throws IOException {
794794
}
795795

796796
if (result == null) {
797-
throw makeException("Can't find file for path \'" + path +
798-
"\' in preprocessing source folders, allowed usage only files in preprocessing source folders!",
797+
throw makeException("Can't find file for path '" + path +
798+
"' in preprocessing source folders, allowed usage only files in preprocessing source folders!",
799799
null);
800800
} else if (!result.isFile()) {
801-
throw makeException("File \'" + result + "\' is either not found or not a file", null);
801+
throw makeException("File '" + result + "' is either not found or not a file", null);
802802
}
803803

804804
} else if (parentDir != null) {
@@ -807,25 +807,24 @@ public File findFileInSources(final String path) throws IOException {
807807
} else {
808808
final List<File> setOfFoundFiles = new ArrayList<>();
809809
getSources().stream().map((root) -> new File(root.getAsFile(), path))
810-
.filter((variant) -> (variant.exists() && variant.isFile())).forEachOrdered((variant) -> {
811-
setOfFoundFiles.add(variant);
812-
});
810+
.filter((variant) -> (variant.exists() && variant.isFile())).forEachOrdered(
811+
setOfFoundFiles::add);
813812

814813
if (setOfFoundFiles.size() == 1) {
815814
result = setOfFoundFiles.get(0);
816815
} else if (setOfFoundFiles.isEmpty()) {
817816
result = null;
818817
} else {
819818
throw makeException(
820-
"Found several variants for path \'" + path + "\' in different source roots", null);
819+
"Found several variants for path '" + path + "' in different source roots", null);
821820
}
822821

823822
if (result == null) {
824-
throw makeException("Can't find file for path \'" + path +
825-
"\' among source files registered for preprocessing.", null);
823+
throw makeException("Can't find file for path '" + path +
824+
"' among source files registered for preprocessing.", null);
826825
} else if (!result.isFile()) {
827-
throw makeException("File \'" + PreprocessorUtils.getFilePath(result) +
828-
"\' is either not found or not a file", null);
826+
throw makeException("File '" + PreprocessorUtils.getFilePath(result) +
827+
"' is either not found or not a file", null);
829828
}
830829
}
831830

jcp/src/main/java/com/igormaznitsa/jcp/directives/DefineDirectiveHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public String getReference() {
6060
protected void process(final PreprocessorContext context, final String varName, final Value value,
6161
final boolean exists) {
6262
if (exists) {
63-
context.logWarning("Variable \'" + varName + "\' already defined");
63+
context.logWarning("Variable '" + varName + "' already defined");
6464
}
6565
context.setGlobalVariable(varName, value);
6666
}

jcp/src/main/java/com/igormaznitsa/jcp/directives/FlushDirectiveHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public AfterDirectiveProcessingBehaviour execute(final String string,
6060
final boolean saved = state.saveBuffersToFile(outFile, context.isKeepComments());
6161
if (context.isVerbose()) {
6262
context.logForVerbose(
63-
"Content was " + (saved ? "saved" : "not saved") + " into file '" + outFile + "\'");
63+
"Content was " + (saved ? "saved" : "not saved") + " into file '" + outFile + "'");
6464
}
6565

6666
state.resetPrinters();

0 commit comments

Comments
 (0)