All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.reactfx.collection.ListModificationLike Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
package org.reactfx.collection;

import java.util.List;

import javafx.collections.ObservableList;

/**
 * Describes an elementary modification made to a list. Elementary modification
 * is represented by the position in the list where the change occurred
 * ({@link #getFrom()}), a list of elements removed by the modification
 * ({@link #getRemoved()}), and the number of added elements replacing the
 * removed elements ({@link #getAddedSize()}).
 *
 * 

Subtypes of this interface differ in how they refer to the added elements: *

    *
  • {@link ListModification} holds a reference to the observable list * in which the modification occurred and the * {@link ListModification#getAddedSubList()} method returns a sublist view * of the original observable list. Such sublist is valid only until the * next list modification. *
  • {@link MaterializedListModification} has its own copy of added * elements ({@link MaterializedListModification#getAdded()}), thus the * validity of the list of added elements returned from {@code getAdded()} * is not restricted. *
  • {@link QuasiListModification} does not provide a way to get the * added elements directly, but has to be combined with the observable list * to obtain {@linkplain ListModification} * ({@link QuasiListModification#instantiate(QuasiListModification, ObservableList)}) * or {@linkplain MaterializedListModification} * ({@link QuasiListModification#materialize(QuasiListModification, ObservableList)}). *
* * @param type of list elements. */ interface ListModificationLike { /** * Returns the position in the list where this change occurred. */ int getFrom(); /** * Returns the number of items removed by this change. */ default int getRemovedSize() { return getRemoved().size(); } /** * Returns the number of items added by this change. */ int getAddedSize(); /** * Returns the end position of the change in the modified list. * The returned value is equal to {@code getFrom() + getAddedSize()}. */ default int getTo() { return getFrom() + getAddedSize(); } /** * Returns an immutable list of elements removed by this change. * Before the change occurred, the first element of the returned list * was at index {@link #getFrom()} in the original list. * If no elements were removed by this change, returns an empty list. * The size of the returned list is equal to the value returned by * {@link #getRemovedSize()}. */ List getRemoved(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy