7 package org.sleuthkit.autopsy.timeline.utils;
9 import java.util.ArrayList;
10 import java.util.List;
11 import java.util.function.Function;
12 import javafx.collections.ListChangeListener;
13 import javafx.collections.ObservableList;
14 import javafx.collections.transformation.TransformationList;
19 public class MappedList<E, F>
extends TransformationList<E, F> {
22 public MappedList(ObservableList<? extends F> source, Function<F, E> mapper) {
33 public E
get(
int index) {
34 return mapper.apply(getSource().
get(index));
39 return getSource().size();
43 protected void sourceChanged(ListChangeListener.Change<? extends F> c) {
44 fireChange(
new ListChangeListener.Change<E>(
this) {
46 public boolean wasAdded() {
51 public boolean wasRemoved() {
52 return c.wasRemoved();
56 public boolean wasReplaced() {
57 return c.wasReplaced();
61 public boolean wasUpdated() {
62 return c.wasUpdated();
66 public boolean wasPermutated() {
67 return c.wasPermutated();
71 public int getPermutation(
int i) {
72 return c.getPermutation(i);
76 protected int[] getPermutation() {
81 throw new AssertionError(
"Unreachable code");
85 public List<E> getRemoved() {
86 ArrayList<E> res =
new ArrayList<>(c.getRemovedSize());
87 for (F e : c.getRemoved()) {
88 res.add(mapper.apply(e));
94 public int getFrom() {
104 public boolean next() {
109 public void reset() {
MappedList(ObservableList<?extends F > source, Function< F, E > mapper)
final Function< F, E > mapper
void sourceChanged(ListChangeListener.Change<?extends F > c)
int getSourceIndex(int index)