mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
Merge pull request #4672 from millmanorama/1216-drop-immutablesets
1216 fix merge
This commit is contained in:
commit
cd2e7159a0
@ -26,11 +26,15 @@ import com.google.common.eventbus.Subscribe;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
@ -287,4 +291,19 @@ final public class DetailsViewModel {
|
||||
.sorted(new DetailViewEvent.StartComparator())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/** Make a sorted copy of the given set using the given comparator to sort
|
||||
* it.
|
||||
*
|
||||
* @param <X> The type of elements in the set.
|
||||
* @param setA The set of elements to copy into the new sorted set.
|
||||
* @param comparator The comparator to sort the new set by.
|
||||
*
|
||||
* @return A sorted copy of the given set.
|
||||
*/
|
||||
static <X> SortedSet<X> copyAsSortedSet(Collection<X> setA, Comparator<X> comparator) {
|
||||
TreeSet<X> treeSet = new TreeSet<>(comparator);
|
||||
treeSet.addAll(setA);
|
||||
return treeSet;
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ package org.sleuthkit.autopsy.timeline.ui.detailview.datamodel;
|
||||
import com.google.common.collect.Sets;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.singleton;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import org.joda.time.Interval;
|
||||
import org.sleuthkit.autopsy.timeline.utils.IntervalUtils;
|
||||
import org.sleuthkit.datamodel.DescriptionLoD;
|
||||
@ -222,7 +222,7 @@ public class EventCluster implements MultiEvent<EventStripe> {
|
||||
|
||||
@Override
|
||||
public SortedSet<EventCluster> getClusters() {
|
||||
return new TreeSet<>(singleton(this));
|
||||
return DetailsViewModel.copyAsSortedSet(singleton(this), Comparator.comparing(cluster -> true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,15 +20,12 @@ package org.sleuthkit.autopsy.timeline.ui.detailview.datamodel;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Collection;
|
||||
import static java.util.Collections.singleton;
|
||||
import java.util.Comparator;
|
||||
import static java.util.Comparator.comparing;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import org.sleuthkit.datamodel.DescriptionLoD;
|
||||
import org.sleuthkit.datamodel.timeline.EventType;
|
||||
|
||||
@ -105,10 +102,9 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
||||
}
|
||||
|
||||
public EventStripe(EventCluster cluster) {
|
||||
this.clusters = copyAsSortedSet(singleton(cluster.withParent(this)),
|
||||
this.clusters = DetailsViewModel.copyAsSortedSet(singleton(cluster.withParent(this)),
|
||||
comparing(EventCluster::getStartMillis));
|
||||
|
||||
|
||||
type = cluster.getEventType();
|
||||
description = cluster.getDescription();
|
||||
lod = cluster.getDescriptionLoD();
|
||||
@ -119,14 +115,14 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
||||
}
|
||||
|
||||
private EventStripe(EventStripe stripeA, EventStripe stripeB) {
|
||||
clusters = copyAsSortedSet(Sets.union(stripeB.getClusters(), stripeB.getClusters()), comparing(EventCluster::getStartMillis));
|
||||
clusters = DetailsViewModel.copyAsSortedSet(Sets.union(stripeA.getClusters(), stripeB.getClusters()), comparing(EventCluster::getStartMillis));
|
||||
|
||||
type = stripeA.getEventType();
|
||||
description = stripeA.getDescription();
|
||||
lod = stripeA.getDescriptionLoD();
|
||||
eventIDs = Sets.union(stripeB.getEventIDs(), stripeB.getEventIDs());
|
||||
tagged = Sets.union(stripeB.getEventIDsWithTags(), stripeB.getEventIDsWithTags());
|
||||
hashHits = Sets.union(stripeB.getEventIDsWithHashHits(), stripeB.getEventIDsWithHashHits());
|
||||
eventIDs = Sets.union(stripeA.getEventIDs(), stripeB.getEventIDs());
|
||||
tagged = Sets.union(stripeA.getEventIDsWithTags(), stripeB.getEventIDsWithTags());
|
||||
hashHits = Sets.union(stripeA.getEventIDsWithHashHits(), stripeB.getEventIDsWithHashHits());
|
||||
parent = stripeA.getParent().orElse(stripeB.getParent().orElse(null));
|
||||
}
|
||||
|
||||
@ -232,10 +228,4 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
||||
return Objects.equals(this.eventIDs, other.eventIDs);
|
||||
}
|
||||
|
||||
private static <X> SortedSet<X> copyAsSortedSet(Collection<X> setA, Comparator<X> comparator) {
|
||||
|
||||
TreeSet<X> treeSet = new TreeSet<>(comparator);
|
||||
treeSet.addAll(setA);
|
||||
return treeSet;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user