Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/changes/changes_4.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ We moved some GitHub action permissions from workflow-level to job-level.

## Security

* #
* #

## Refactoring

* #544: Replaced optional parameter with null check
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.itsallcode.openfasttrace.api.importer.ImportEventListener;
import org.itsallcode.openfasttrace.api.importer.Importer;
Expand All @@ -25,21 +24,21 @@ class TagImporter implements Importer
this.file = file;
}

static TagImporter create(final Optional<PathConfig> config, final InputFile file,
static TagImporter create(final PathConfig config, final InputFile file,
final ImportEventListener listener)
{
final LineConsumer lineConsumer = createLineConsumer(config, file, listener);
return new TagImporter(lineConsumer, file);
}

private static LineConsumer createLineConsumer(final Optional<PathConfig> config,
final InputFile file, final ImportEventListener listener)
private static LineConsumer createLineConsumer(final PathConfig config, final InputFile file,
final ImportEventListener listener)
{
final List<LineConsumer> importers = new ArrayList<>();
importers.add(new LongTagImportingLineConsumer(file, listener));
if (config.isPresent())
if (config != null)
{
importers.add(new ShortTagImportingLineConsumer(config.get(), file, listener));
importers.add(new ShortTagImportingLineConsumer(config, file, listener));
}
return new DelegatingLineConsumer(importers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Importer createImporter(final InputFile path, final ImportEventListener l
+ DEFAULT_FILE_REGEX + " and " + getPathConfigs().toList());
}
final Optional<PathConfig> config = findConfig(path);
return TagImporter.create(config, path, listener);
return TagImporter.create(config.orElse(null), path, listener);
}

private Stream<PathConfig> getPathConfigs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.io.StringReader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

import org.itsallcode.openfasttrace.api.core.SpecificationItemId;
import org.itsallcode.openfasttrace.api.importer.ImportEventListener;
Expand Down Expand Up @@ -152,6 +151,6 @@ private void runImport(final String content)
final InputFile file = StreamInput.forReader(FILE,
new BufferedReader(new StringReader(content)));

TagImporter.create(Optional.of(this.configMock), file, this.listenerMock).runImport();
TagImporter.create(this.configMock, file, this.listenerMock).runImport();
}
}
Loading