feat: extract interface HierarchicalTreeData from TreeData#23950
feat: extract interface HierarchicalTreeData from TreeData#23950sclassen wants to merge 8 commits intovaadin:mainfrom
Conversation
TreeDataProvider currently takes a TreeData as its source. But it relies only on a few methods of TreeData. This change extracts those methods into an interface. It then introduces a super class to TreeDataProvider which accepts a HierarchicalTreeData instead of a TreeData. A client has now the choice to either use the TreeData and the TreeDataProvider, or it can implement the HierarchicalTreeData interface and use the HierarchicalTreeDataProvider. This change introduces a new interface and a class but does not change or break any existing API. Fixes vaadin#9808
50682ae to
510379c
Compare
|
This is the minimal change I could find to satisfy the desire to have a custom tree data implementation as it is expressed in #9808.
The name of the new interface is semi optimal, as "hierarchical" is already used in other class names with a slightly different semantics. |
This second gerenic parameter represents the concrete type of the HierarchicalTreeData. Having this as a generic parameter allows for better type safty. The client of the provider can get the underlying data structure in a type safe manner. This eases writing stable code.
flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalTreeData.java
Outdated
Show resolved
Hide resolved
flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalData.java
Show resolved
Hide resolved
...data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalTreeDataProvider.java
Outdated
Show resolved
Hide resolved
...data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalTreeDataProvider.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/vaadin/flow/data/provider/hierarchy/InMemoryHierarchicalDataProvider.java
Show resolved
Hide resolved
- rename HierarchicalTreeDataProvider.java -> InMemoryHierarchicalDataProvider.java - rename HierarchicalTreeData.java -> HierarchicalData.java - add method InMemoryHierarchicalDataProvider.getHierarchicalData()
|
I am not sure why this PR has the +1.0.0 tag. From my perspective this should qualify as a +0.1.0. |
flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/TreeDataProvider.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/vaadin/flow/data/provider/hierarchy/InMemoryHierarchicalDataProvider.java
Outdated
Show resolved
Hide resolved
It fell back to |
|



Description
TreeDataProvider currently takes a TreeData as its source. But it relies only on a few methods of TreeData.
This change extracts those methods into an interface. It then introduces a super class to TreeDataProvider which accepts a HierarchicalTreeData instead of a TreeData. A client has now the choice to either use the TreeData and the TreeDataProvider, or it can implement the HierarchicalTreeData interface and use the HierarchicalTreeDataProvider.
This change introduces a new interface and a new class but does not change or break any existing API.
Fixes #9808
Type of change
Checklist
Additional for
Featuretype of change