Open mvysny opened 4 years ago
@mvysny, it seems that this is not a recommended pattern. See here for more details.
Can you provide a code sample (or link to one) for how exactly you are using the fetchChildrenFromBackEnd
method? There might be a better solution.
@jhult I think that particular FindBugs rule does not apply here: the rule discusses List and makes the point by trying to insert a Cat into the List. In this case we have a Stream which is a read-only API with no mutation parameters.
Can you provide a code sample (or link to one) for how exactly you are using the fetchChildrenFromBackEnd method? There might be a better solution.
It's the other way around: the Grid is calling fetchChildrenFromBackEnd() to populate itself; I'm merely trying to implement a HierarchicalDataProvider which on root level is trying to return List<ItemGroup>
and on a non-root level it's trying to return List<ItemLeaf>
.
Maybe I should provide a more concrete example, but I can't - it's customer's code and I can't make it public. I could make similar case by showing a simple file-system and having List<Directory>
and List<File>
, but I hoped that the issue description would be enough...
At least the changes proposed in #7653 would be breaking changes and the added value is too small compared to the potential harm it would cause.
I think the added value is more significant for TreeGrid
and thus it could be perhaps done only for AbstractHierarchicalDataProvider
which probably doesn't have that many implementations, but there potentially breaking some applications could be more adjust.
Loosely connected to #6617 but the use-case for this is different.
My use-case is that I have a
TreeGrid<Item>
with various types of items: anItemGroup
represents inner nodes, while anItemLeaf
represents leaves, and both of them implement theItem
interface.I have an API which returns
List<ItemLeaf>
(List<ItemLeaf> findLeavesForGroup(long groupId)
) which I would like to simply return fromAbstractBackEndHierarchicalDataProvider.fetchChildrenFromBackEnd()
, but I can't:list.stream()
is of typeStream<ItemLeaf>
, yetStream<Item>
is expected.If
fetchChildrenFromBackEnd()
would returnStream<? extends Item>
then returningStream<ItemLeaf>
would be possible.Vaadin 14.0.12