Skip to content

Commit

Permalink
Support filtering on multiple keys
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jan 6, 2022
1 parent 708ea17 commit ee16708
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/ContentCollection.java
@@ -1,6 +1,7 @@
package net.fortuna.ical4j.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -29,8 +30,9 @@ public interface ContentCollection<T extends Content> extends Serializable {
List<T> getAll();

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

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit ee16708

Please sign in to comment.