Package com.oorian.data
Interface HierarchicalDataProvider<T>
- Type Parameters:
T- the data item type
- All Superinterfaces:
DataProvider<T>
Extension of
DataProvider for tree-structured data.
Provides methods for fetching child items, counting children, and checking whether an item has children. Used by tree grids, tree tables, and tree views.
HierarchicalDataProvider<Department> provider = new HierarchicalDataProvider<Department>() {
@Override
public DataResult<Department> fetchChildren(Department parent, Query query) {
List<Department> children = departmentDao.getChildren(
parent == null ? null : parent.getId(),
query.getOffset(), query.getLimit());
int total = departmentDao.getChildCount(
parent == null ? null : parent.getId());
return DataResult.of(children, total);
}
@Override
public int getChildCount(Department parent, Query query) {
return departmentDao.getChildCount(
parent == null ? null : parent.getId());
}
@Override
public boolean hasChildren(Department item) {
return departmentDao.hasChildren(item.getId());
}
};
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfetchChildren(T parent, Query query) Fetches child items of the given parent.intgetChildCount(T parent, Query query) Returns the number of children for the given parent.booleanhasChildren(T item) Returns whether the given item has any children.Methods inherited from interface com.oorian.data.DataProvider
addDataChangeListener, fetch, refresh, removeDataChangeListener, size
-
Method Details
-
fetchChildren
Fetches child items of the given parent.Pass
nullas the parent to fetch root-level items.- Parameters:
parent- the parent item, ornullfor root itemsquery- the query with offset, limit, sorts, and filters- Returns:
- the result containing child items and total child count
-
getChildCount
Returns the number of children for the given parent.- Parameters:
parent- the parent item, ornullfor root itemsquery- the query (only filters are relevant)- Returns:
- the number of child items
-
hasChildren
Returns whether the given item has any children.Used by tree components to determine whether to show an expand indicator.
- Parameters:
item- the item to check- Returns:
trueif the item has children
-