blob: 2b7ce80724b1f5a59b2ad5228dc1029f3f7200d4 (
plain)
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
|
package de.cowtipper.cowlection.search;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class LogSearchResults {
private final AtomicInteger analyzedFiles;
private final AtomicInteger skippedFiles;
private final List<LogEntry> searchResults;
private int analyzedFilesWithHits;
public LogSearchResults() {
this.analyzedFiles = new AtomicInteger();
this.skippedFiles = new AtomicInteger();
this.searchResults = Collections.synchronizedList(new ArrayList<>());
}
public void addAnalyzedFile() {
analyzedFiles.incrementAndGet();
}
public void addSkippedFile() {
skippedFiles.incrementAndGet();
}
public void addSearchResults(List<LogEntry> newResults) {
searchResults.addAll(newResults);
}
public void setAnalyzedFilesWithHits(int analyzedFilesWithHits) {
this.analyzedFilesWithHits = analyzedFilesWithHits;
}
public int getAnalyzedFiles() {
return analyzedFiles.get();
}
public int getSkippedFiles() {
return skippedFiles.get();
}
public List<LogEntry> getSortedSearchResults() {
return searchResults.stream().sorted(Comparator.comparing(LogEntry::getTime)).collect(Collectors.toList());
}
public int getAnalyzedFilesWithHits() {
return analyzedFilesWithHits;
}
}
|