From eb57361b6f1f30f02315e2eade9a8fda0fdbe82f Mon Sep 17 00:00:00 2001 From: millmanorama Date: Fri, 9 Jun 2017 11:14:11 +0200 Subject: [PATCH] suppress compile type warnings --- .../corecomponents/ResultViewerPersistence.java | 2 +- .../corecomponents/ThumbnailViewChildren.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/ResultViewerPersistence.java b/Core/src/org/sleuthkit/autopsy/corecomponents/ResultViewerPersistence.java index 148d3aca74..7d03ec65eb 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/ResultViewerPersistence.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/ResultViewerPersistence.java @@ -172,7 +172,7 @@ final class ResultViewerPersistence { } /** - * Encapsulate the property sort order and sort rank into onde data bag. + * Encapsulate the property, sort order, and sort rank into one data bag. */ static class SortCriterion { diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/ThumbnailViewChildren.java b/Core/src/org/sleuthkit/autopsy/corecomponents/ThumbnailViewChildren.java index d9a002ae71..5fb210ee0b 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/ThumbnailViewChildren.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/ThumbnailViewChildren.java @@ -32,6 +32,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.function.Function; import java.util.logging.Level; import java.util.stream.Collectors; import javax.swing.SortOrder; @@ -163,17 +164,25 @@ class ThumbnailViewChildren extends Children.Keys { } private Comparator getCriterionComparator(SortCriterion criterion) { + @SuppressWarnings("unchecked") Comparator c = Comparator.comparing(node -> getPropertyValue(node, criterion.getProperty()), Comparator.nullsFirst(Comparator.naturalOrder())); return criterion.getSortOrder() == SortOrder.ASCENDING ? c : c.reversed(); } + @SuppressWarnings("rawtypes") private Comparable getPropertyValue(Node node, Node.Property prop) { for (Node.PropertySet ps : node.getPropertySets()) { for (Node.Property p : ps.getProperties()) { if (p.equals(prop)) { try { - return (Comparable) p.getValue(); + if (p.getValue() instanceof Comparable) { + return (Comparable) p.getValue(); + } else { + //if the value is not comparable use its string representation + return p.getValue().toString(); + } + } catch (IllegalAccessException | InvocationTargetException ex) { Exceptions.printStackTrace(ex); } @@ -221,7 +230,7 @@ class ThumbnailViewChildren extends Children.Keys { */ private class ThumbnailViewNode extends FilterNode { - private final Logger logger = Logger.getLogger(ThumbnailViewNode.class.getName()); + private final Logger logger = Logger.getLogger(ThumbnailViewNode.class.getName()); private final Image waitingIcon = Toolkit.getDefaultToolkit().createImage(ThumbnailViewNode.class.getResource("/org/sleuthkit/autopsy/images/working_spinner.gif"));