This repository was archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathConfiguration.java
62 lines (51 loc) · 2.12 KB
/
Configuration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package jb.configuration;
import java.nio.file.Path;
import java.util.function.Predicate;
public class Configuration {
public static class ConfigurationBuilder {
private JavaParserAdapter javaParserAdapter = new PrettyPrint();
private ChangeWriter changeWriter = new FileWriter();
private boolean skipFilesWithUnsupportedFeatures = false;
private Predicate<Path> exclude = path -> false;
/**
* run the complete conversion but do not update the files
*/
public ConfigurationBuilder dryRun() {
changeWriter = new DryRun();
return this;
}
/**
* preserves the formatting of the source files as good as this
* is supported by the java-parser library
*/
public ConfigurationBuilder preserveFormatting() {
this.javaParserAdapter = new PreserveFormatting();
return this;
}
/**
* This detection is very limited. Right now only @RunWith and @Rule
* usages are detected and reported as unsupported. Have a look at
* {@link jb.convert.ast.RunnerReporter} and {@link jb.convert.ast.RuleReporter}
*/
public ConfigurationBuilder skipFilesWithUnsupportedFeatures() {
skipFilesWithUnsupportedFeatures = true;
return this;
}
/**
* You may have some java files in your code that can not be properly handled
* by the conversion. Use this to exclude them from being processed.
*
* @param exclude all files this predicated matches are excluded from the conversion
*/
public ConfigurationBuilder excludeMatching(Predicate<Path> exclude) {
this.exclude = exclude;
return this;
}
public JunitConversionLogicConfiguration build() {
return new JunitConversionLogicConfiguration(javaParserAdapter, changeWriter, skipFilesWithUnsupportedFeatures, exclude);
}
}
public static JunitConversionLogicConfiguration prettyPrintAndPersistChanges() {
return new ConfigurationBuilder().build();
}
}