Interface VFXMappingTableCell<T,E>

Type Parameters:
T - the data type in the table
E - the data type the cell is going to use from items of type T
All Superinterfaces:
VFXCell<T>, VFXTableCell<T>
All Known Implementing Classes:
VFXObservingTableCell, VFXSimpleTableCell

public interface VFXMappingTableCell<T,E> extends VFXTableCell<T>
Extension of VFXTableCell to propose users a specific way of using VFXTable. I structured this virtualized container with this API in mind. Each VFXTableColumn should produce cells that display from an object T that comes from the model, a piece of data E which is part of T. Consider this example:

// My model class...
record User(int id, String name) {}
// My columns (assuming UserCell is a custom cell)
VFXTableColumn<User, UserCell> idColumn = new VFXDefaultTableColumn<>("ID");
VFXTableColumn<User, UserCell> nameColumn = new VFXDefaultTableColumn<>("Name");
// Let's set their cell factories
idColumn.setCellFactory(user -> new UserCell(user, User::id));
nameColumn.setCellFactory(user -> new UserCell(user, User::name));
// See the second parameter in the constructors? I call that function the 'extractor' which basically tells the cell
// which piece of data it should display from the a User object

For this API to work, we need two additional requirements:

1) Cells need to have an 'extractor' function

2) Cells may want to also have a 'converter' function. This is going to be used to convert extracted data of type E to string to be used, for example, in a label. Of course, this is optional if the data is not going to be displayed as a string

  • Method Details

    • getExtractor

      Function<T,E> getExtractor()
      Returns:
      the function used to extract a value E from an item T
    • setExtractor

      VFXMappingTableCell<T,E> setExtractor(Function<T,E> extractor)
      Sets the function used to extract a value E from an item T
    • getConverter

      javafx.util.StringConverter<E> getConverter()
      Returns:
      the StringConverter used to convert an extracted value E to a String
    • setConverter

      VFXMappingTableCell<T,E> setConverter(javafx.util.StringConverter<E> converter)
      Sets the StringConverter used to convert an extracted value E to a String
    • setConverter

      default VFXMappingTableCell<T,E> setConverter(Function<E,String> fn)
      Allows easily setting a StringConverter for the cell by just giving a Function as parameter, makes use of FunctionalStringConverter.to(Function).