Vaadin Tree - Disable selection of parent while retain selection of child e

This is the code I have created for the construction of Tree with data stored in a .json file retrieved in Arraylist. How to disable selection of parent elements alone

Data will look like for example

Parent 1
  Child 1.1
  Child 1.2
Parent 2
   Child 2.1
    Child 2.2

Only Children 1.1,1.2 and 2.1,2.2 should be selectable. Parent 1 and Parent 2 should not be selectable. How to implement this?


 `dashboardSelectionItems = mockDashboardSelectionProvider.fetchDashboardSelection();  `  // This contains data in the form of ArrayList

    TreeData<DashboardSelectionItem> treeData = new TreeData<>();
    treeData.addItems(null,dashboardSelectionItems);

    dashboardSelectionItems.forEach(dashboardSelectionItem -> treeData.addItems(dashboardSelectionItem,dashboardSelectionItem.getData()));
    TreeDataProvider<DashboardSelectionItem> dataProvider = new TreeDataProvider<>(treeData);
    selectionItems.setCaption("Selection");
    selectionItems.setDataProvider(dataProvider);
    selectionItems.setItemCaptionGenerator(DashboardSelectionItem::getTitle);

    selectionItems.asSingleSelect().addValueChangeListener(event -> {
      if (event.getValue() != null) {
        id = event.getValue().getId();
        descriptionText = event.getValue().getDescription();
        itemText = event.getValue().getTitle();
        if(descriptionText !=null && !"".equals(descriptionText)) {
          description.setPlaceholder(descriptionText);
        } else {
          description.setPlaceholder("");
        }
      }
    });`