Skip to content

Commit

Permalink
Support typed list
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Apr 9, 2021
1 parent f9a5da1 commit 33e557b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/ContentContainer.java
Expand Up @@ -20,8 +20,9 @@ public interface ContentContainer<T extends Content> extends Serializable {

List<T> getAll();

default List<T> get(String name) {
return getAll().stream().filter(c -> c.getName().equals(name)).collect(Collectors.toList());
@SuppressWarnings("unchecked")
default <R extends T> List<R> get(String name) {
return getAll().stream().filter(c -> c.getName().equals(name)).map(c -> (R) c).collect(Collectors.toList());
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit 33e557b

Please sign in to comment.