aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-01-11 00:34:07 +0800
committershedaniel <daniel@shedaniel.me>2020-01-11 00:34:07 +0800
commita855c0284c3b285dd8a71b57ec35702995ae5b30 (patch)
tree4b2876163d99301960a26ff821aff5c97e3fb02e /src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
parentbde33221f4e4732daafdc9ecd3a0e559c1f74ed2 (diff)
downloadRoughlyEnoughItems-a855c0284c3b285dd8a71b57ec35702995ae5b30.tar.gz
RoughlyEnoughItems-a855c0284c3b285dd8a71b57ec35702995ae5b30.tar.bz2
RoughlyEnoughItems-a855c0284c3b285dd8a71b57ec35702995ae5b30.zip
3.3.7
Diffstat (limited to 'src/main/java/me/shedaniel/rei/utils/CollectionUtils.java')
-rw-r--r--src/main/java/me/shedaniel/rei/utils/CollectionUtils.java8
1 files changed, 8 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 296c9c747..44d6f5f6d 100644
--- a/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
+++ b/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
@@ -16,6 +16,14 @@ import java.util.function.Predicate;
@Internal
public class CollectionUtils {
+ public static <A, B> List<B> getOrPutEmptyList(Map<A, List<B>> map, A key) {
+ List<B> b = map.get(key);
+ if (b != null)
+ return b;
+ map.put(key, Lists.newArrayList());
+ return map.get(key);
+ }
+
public static <T> T findFirstOrNullEquals(List<T> list, T obj) {
for (T t : list) {
if (t.equals(obj))