package net.minecraft.advancements.critereon; import com.mojang.serialization.Codec; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; public interface CollectionContentsPredicate> extends Predicate> { List

unpack(); static > Codec> codec(Codec

p_330819_) { return p_330819_.listOf().xmap(CollectionContentsPredicate::of, CollectionContentsPredicate::unpack); } @SafeVarargs static > CollectionContentsPredicate of(P... p_329822_) { return of(List.of(p_329822_)); } static > CollectionContentsPredicate of(List

p_330160_) { return (CollectionContentsPredicate)(switch (p_330160_.size()) { case 0 -> new CollectionContentsPredicate.Zero(); case 1 -> new CollectionContentsPredicate.Single(p_330160_.getFirst()); default -> new CollectionContentsPredicate.Multiple(p_330160_); }); } public static record Multiple>(List

tests) implements CollectionContentsPredicate { public boolean test(Iterable p_334780_) { List> list = new ArrayList<>(this.tests); for (T t : p_334780_) { list.removeIf(p_331259_ -> p_331259_.test(t)); if (list.isEmpty()) { return true; } } return false; } @Override public List

unpack() { return this.tests; } } public static record Single>(P test) implements CollectionContentsPredicate { public boolean test(Iterable p_332451_) { for (T t : p_332451_) { if (this.test.test(t)) { return true; } } return false; } @Override public List

unpack() { return List.of(this.test); } } public static class Zero> implements CollectionContentsPredicate { public boolean test(Iterable p_333955_) { return true; } @Override public List

unpack() { return List.of(); } } }