File tree Expand file tree Collapse file tree
src/main/java/org/pwss/model/table Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,19 +25,25 @@ public class DiffTableModel extends AbstractTableModel {
2525 "👮 Quarantine" };
2626
2727 /**
28- * Constructs a new DiffTableModel with the specified list of diffs.
28+ * Constructs a new DiffTableModel with the provided list of Diff objects.
29+ * Filters the data to ensure only unique entries are included based on the file ID.
2930 *
30- * @param data the list of Diff objects to be displayed in the table
31+ * @param data The list of Diff objects to be displayed in the table.
3132 */
3233 public DiffTableModel (List <Diff > data ) {
33-
3434 this .data = data .stream ()
3535 .filter (distinctByKey (diff -> diff .integrityFail ().file ().id ()))
3636 .toList ();
3737 this .metadataManager = new MetadataManager ();
3838 }
3939
40- // TODO: Add Java Docs
40+ /**
41+ * Returns a filter that only allows unique elements, based on a property from each item.
42+ *
43+ * @param <T> The type of items to filter.
44+ * @param keyExtractor A function to get the property used for checking uniqueness.
45+ * @return A filter that returns true for the first time it sees a property value, false after.
46+ */
4147 private <T > Predicate <T > distinctByKey (Function <? super T , ?> keyExtractor ) {
4248 Set <Object > seen = ConcurrentHashMap .newKeySet ();
4349 return t -> seen .add (keyExtractor .apply (t ));
You can’t perform that action at this time.
0 commit comments