Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
*/
public class JsonReader implements DocumentReader {

private Resource resource;
private final Resource resource;

private JsonMetadataGenerator jsonMetadataGenerator;
private final JsonMetadataGenerator jsonMetadataGenerator;

private final ObjectMapper objectMapper = new ObjectMapper();

/**
* The key from the JSON that we will use as the text to parse into the Document text
*/
private List<String> jsonKeysToUse;
private final List<String> jsonKeysToUse;

public JsonReader(Resource resource) {
this(resource, new ArrayList<>().toArray(new String[0]));
this(resource, new String[0]);
}

public JsonReader(Resource resource, String... jsonKeysToUse) {
Expand Down Expand Up @@ -92,9 +92,9 @@ public List<Document> get() {
private Document parseJsonNode(JsonNode jsonNode, ObjectMapper objectMapper) {
Map<String, Object> item = objectMapper.convertValue(jsonNode, new TypeReference<Map<String, Object>>() {
});
StringBuffer sb = new StringBuffer();
var sb = new StringBuilder();

jsonKeysToUse.parallelStream().filter(item::containsKey).forEach(key -> {
jsonKeysToUse.stream().filter(item::containsKey).forEach(key -> {
sb.append(key).append(": ").append(item.get(key)).append(System.lineSeparator());
});

Expand Down