aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-02-21 22:12:48 +0800
committershedaniel <daniel@shedaniel.me>2020-02-21 22:13:05 +0800
commit490a2e3fdd124562ed09f048beec5178555a36a4 (patch)
tree35ae6c80dcde25fd829ef8c7ecbde71367947656 /src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
parent4987103190a8bea7c8954512c389f9e768b8d5b3 (diff)
downloadRoughlyEnoughItems-490a2e3fdd124562ed09f048beec5178555a36a4.tar.gz
RoughlyEnoughItems-490a2e3fdd124562ed09f048beec5178555a36a4.tar.bz2
RoughlyEnoughItems-490a2e3fdd124562ed09f048beec5178555a36a4.zip
4.0.4
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/utils/CollectionUtils.java')
-rw-r--r--src/main/java/me/shedaniel/rei/utils/CollectionUtils.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java b/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
index 95d730f64..d364708de 100644
--- a/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
+++ b/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
@@ -32,6 +32,15 @@ public class CollectionUtils {
return null;
}
+ public static <T,R> List<R> castAndMap(List<T> list, Class<R> castClass) {
+ List<R> l = new ArrayList<>();
+ for (T t : list) {
+ if (castClass.isAssignableFrom(t.getClass()))
+ l.add((R) t);
+ }
+ return l;
+ }
+
public static <T> T findFirstOrNull(List<T> list, Predicate<T> predicate) {
for (T t : list) {
if (predicate.test(t))