mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 22:08:01 -05:00
Refactor OriginalOrder
This commit is contained in:
parent
2eaac2eab8
commit
b1d48fe590
@ -54,7 +54,7 @@ class AutoDetectMatcher implements AutoCompleteMatcher {
|
|||||||
log.log(Level.WARNING, "Failed group: " + it.getKey(), e);
|
log.log(Level.WARNING, "Failed group: " + it.getKey(), e);
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}).sorted(comparing(Match::getValue, new OriginalOrder<File>(files))).collect(toList());
|
}).sorted(comparing(Match::getValue, OriginalOrder.of(files))).collect(toList());
|
||||||
} finally {
|
} finally {
|
||||||
workerThreadPool.shutdownNow();
|
workerThreadPool.shutdownNow();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
matches.addAll(derivateMatches);
|
matches.addAll(derivateMatches);
|
||||||
|
|
||||||
// restore original order
|
// restore original order
|
||||||
matches.sort(comparing(Match::getValue, new OriginalOrder<File>(files)));
|
matches.sort(comparing(Match::getValue, OriginalOrder.of(files)));
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ class MovieMatcher implements AutoCompleteMatcher {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// restore original order
|
// restore original order
|
||||||
matches.sort(comparing(Match::getValue, new OriginalOrder<File>(files)));
|
matches.sort(comparing(Match::getValue, OriginalOrder.of(files)));
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
class OriginalOrder<T> implements Comparator<T> {
|
class OriginalOrder<T> implements Comparator<T> {
|
||||||
|
|
||||||
|
public static <T> Comparator<T> of(Collection<T> values) {
|
||||||
|
return new OriginalOrder(values);
|
||||||
|
}
|
||||||
|
|
||||||
private Map<T, Integer> index;
|
private Map<T, Integer> index;
|
||||||
|
|
||||||
public OriginalOrder(Collection<T> values) {
|
public OriginalOrder(Collection<T> values) {
|
||||||
|
Loading…
Reference in New Issue
Block a user