Class CellFactory<T, C extends VFXCell<T>>
java.lang.Object
io.github.palexdev.virtualizedfx.properties.CellFactory<T,C>
- All Implemented Interfaces:
Observable,Property<Function<T,,C>> ReadOnlyProperty<Function<T,,C>> ObservableValue<Function<T,,C>> WritableValue<Function<T,C>>
A wrapper for cell creation functions used by virtualized containers.
Encapsulates a cell generation function (create(Object)) along with a reference to the VFXContext of
the container that uses the factory.
This allows each created cell to access the container's context upon creation. In other words, this wrapper is an easy way to provide all cells the container's instance as well as additional services without radical API changes.
Note 1: nothing prevents you from creating cells using the function directly, however, keep in mind that to automatically make use of the new
VFXCell.onCreated(VFXContext) hook, you must use create(Object)
instead.
Note 2: for convenience this extends
Property and delegates the implemented methods to the wrapped
cell factory property.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(InvalidationListener listener) voidaddListener(ChangeListener<? super Function<T, C>> listener) voidbind(ObservableValue<? extends Function<T, C>> observable) voidbindBidirectional(Property<Function<T, C>> other) booleanConvenience method to check whether the cell generating function is notnull.context()Creates a new cell for the given item, using the current cell factory function.getBean()getName()getOwner()getValue()booleanisBound()protected voidonInvalidated(Function<T, C> newFactory) Hook method called when the cell factory function is invalidated.voidremoveListener(InvalidationListener listener) voidremoveListener(ChangeListener<? super Function<T, C>> listener) voidvoidunbind()voidunbindBidirectional(Property<Function<T, C>> other) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javafx.beans.Observable
subscribe
-
Constructor Details
-
CellFactory
-
-
Method Details
-
create
Creates a new cell for the given item, using the current cell factory function.If the factory function is set, it generates a cell, calls
VFXCell.onCreated(VFXContext)on it, and then returns it. Returnsnullif no factory function is defined. -
onInvalidated
-
bind
-
unbind
-
isBound
-
bindBidirectional
-
unbindBidirectional
-
getBean
- Specified by:
getBeanin interfaceReadOnlyProperty<T>
-
getName
- Specified by:
getNamein interfaceReadOnlyProperty<T>
-
addListener
- Specified by:
addListenerin interfaceObservableValue<T>
-
removeListener
- Specified by:
removeListenerin interfaceObservableValue<T>
-
getValue
- Specified by:
getValuein interfaceObservableValue<T>- Specified by:
getValuein interfaceWritableValue<T>
-
addListener
- Specified by:
addListenerin interfaceObservable
-
removeListener
- Specified by:
removeListenerin interfaceObservable
-
setValue
-
context
- Returns:
- the virtualized container's
VFXContextinstance.
-
getOwner
- Returns:
- the container that owns this cell factory and inherently the cells created by it.
-
canCreate
public boolean canCreate()Convenience method to check whether the cell generating function is notnull.
-