Vaadin components (e.g. Tree) with methods using Streams and Collections should be relaxed to ? extends T
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Currently (8.4.2), Vaadin components that are generic (such as com.vaadin.ui.Tree) and that have methods that can produce data from a Stream and/or Collection objects (such as Tree::addItems) are constrained to use objects of the instance's exact generic type. Relaxing the requirement to something that extends the generic type would greatly improve user-land usability.
Current Solution:
public TreeData<T> addItems(T parent, Stream<T> items) { ... }
public TreeData<T> addItems(T parent, Collection<T> items) { ... }
Proposed Improved Solution:
public TreeData<T> addItems(T parent, Stream<? extends T> items) { ... }
public TreeData<T> addItems(T parent, Collection<? extends T> items) { ... }
If the proposed improvement is introduced, we could write code like this:
Tree<Car> tree = new Tree<>();
tree.addItems(root, Stream.of(new Volvo(), new Tesla(), new Ford());
provided that all the concrete car classes implements Car. This would simplify building trees with heterogeneous types.
PECS = (Producer Extends, Consumer Super)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Tree::addItems and the related generic component methods that accept Stream or Collection values. Compare their current generic bounds with the proposed bounds and identify the affected APIs; done means compatible heterogeneous subtype collections or streams are accepted without breaking existing calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100