package envoy.client.ui.listcell;
import java.util.function.Function;
import javafx.scene.Node;
import javafx.scene.control.ListView;
/**
* A generic list cell rendering an item using a provided render function.
*
* Project: envoy-client
* File: GenericListCell.java
* Created: 18.07.2020
*
* @author Kai S. K. Engelbart
* @param the type of element displayed by the list cell
* @param the type of node as which the list element will be displayed
* @since Envoy Client v0.2-beta
*/
public final class GenericListCell extends AbstractListCell {
private final Function super T, U> renderer;
/**
* @param listView the list view inside of which the cell will be displayed
* @param renderer a function converting a list item to a node
* @since Envoy Client v0.1-beta
*/
public GenericListCell(ListView extends T> listView, Function super T, U> renderer) {
super(listView);
this.renderer = renderer;
}
@Override
protected U renderItem(T item) { return renderer.apply(item); }
}