Minor refactoring for tool tasks
- Don't scan for translations on initialization in TranslationPageGenerator in order to speed up startup time of ToolsRunner - Extract checking for null / empty array of File#listFiles into a separate method - Move single method of RuntimeUtils into Utils class
This commit is contained in:
@@ -34,8 +34,6 @@ public class TranslationPageGenerator implements AutoToolTask {
|
||||
private static final int[] COLOR_1 = {12, 9, 0};
|
||||
private static final int[] COLOR_2 = { 6, 15, 6};
|
||||
|
||||
private final TranslationsGatherer gatherer = new TranslationsGatherer();
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "updateTranslations";
|
||||
@@ -43,6 +41,7 @@ public class TranslationPageGenerator implements AutoToolTask {
|
||||
|
||||
@Override
|
||||
public void executeDefault() {
|
||||
TranslationsGatherer gatherer = new TranslationsGatherer();
|
||||
NestedTagValue translationValuesHolder = new NestedTagValue();
|
||||
|
||||
for (TranslationInfo translation : gatherer.getTranslationInfo()) {
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static tools.utils.FileIoUtils.listFilesOrThrow;
|
||||
|
||||
/**
|
||||
* Gathers all available translations of AuthMe.
|
||||
*/
|
||||
@@ -31,10 +33,7 @@ public class TranslationsGatherer {
|
||||
}
|
||||
|
||||
private void gatherTranslations() {
|
||||
File[] files = new File(MESSAGES_FOLDER).listFiles();
|
||||
if (files == null) {
|
||||
throw new IllegalStateException("Cannot read files of '" + MESSAGES_FOLDER + "'");
|
||||
}
|
||||
File[] files = listFilesOrThrow(new File(MESSAGES_FOLDER));
|
||||
for (File file : files) {
|
||||
String code = getLanguageCode(file.getName());
|
||||
if (code != null) {
|
||||
|
||||
Reference in New Issue
Block a user