|
2 | 2 | // Licensed under the MIT license.
|
3 | 3 | package com.mojang.datafixers;
|
4 | 4 |
|
5 |
| -import com.google.common.collect.Maps; |
6 | 5 | import com.mojang.datafixers.util.Either;
|
7 | 6 | import com.mojang.datafixers.util.Pair;
|
| 7 | +import com.mojang.datafixers.util.Triple; |
8 | 8 | import com.mojang.datafixers.util.Unit;
|
9 |
| -import com.mojang.datafixers.kinds.App2; |
10 | 9 | import com.mojang.datafixers.schemas.Schema;
|
11 | 10 | import com.mojang.datafixers.types.Func;
|
12 | 11 | import com.mojang.datafixers.types.Type;
|
|
33 | 32 | import com.mojang.datafixers.types.templates.Tag;
|
34 | 33 | import com.mojang.datafixers.types.templates.TaggedChoice;
|
35 | 34 | import com.mojang.datafixers.types.templates.TypeTemplate;
|
36 |
| -import org.apache.commons.lang3.ArrayUtils; |
37 |
| -import org.apache.commons.lang3.tuple.Triple; |
38 | 35 |
|
| 36 | +import java.util.Arrays; |
39 | 37 | import java.util.Map;
|
| 38 | +import java.util.concurrent.ConcurrentHashMap; |
40 | 39 | import java.util.function.Function;
|
41 | 40 | import java.util.function.Supplier;
|
42 | 41 | import java.util.stream.Collectors;
|
@@ -168,7 +167,9 @@ static TypeTemplate and(final TypeTemplate first, final TypeTemplate... rest) {
|
168 | 167 | }
|
169 | 168 |
|
170 | 169 | static TypeTemplate allWithRemainder(final TypeTemplate first, final TypeTemplate... rest) {
|
171 |
| - return and(first, ArrayUtils.add(rest, remainder())); |
| 170 | + TypeTemplate[] templates = Arrays.copyOf(rest, rest.length + 1); |
| 171 | + templates[rest.length] = remainder(); |
| 172 | + return and(first, templates); |
172 | 173 | }
|
173 | 174 |
|
174 | 175 | static <F, G> Type<Pair<F, G>> and(final Type<F> first, final Type<G> second) {
|
@@ -213,7 +214,7 @@ static <K> TaggedChoice<K> taggedChoiceLazy(final String name, final Type<K> key
|
213 | 214 |
|
214 | 215 | @SuppressWarnings("unchecked")
|
215 | 216 | static <K> Type<Pair<K, ?>> taggedChoiceType(final String name, final Type<K> keyType, final Map<K, Type<?>> types) {
|
216 |
| - return (Type<Pair<K, ?>>) Instances.TAGGED_CHOICE_TYPE_CACHE.computeIfAbsent(Triple.of(name, keyType, types), k -> new TaggedChoice.TaggedChoiceType<>(k.getLeft(), (Type<K>) k.getMiddle(), (Map<K, Type<?>>) k.getRight())); |
| 217 | + return (Type<Pair<K, ?>>) Instances.TAGGED_CHOICE_TYPE_CACHE.computeIfAbsent(Triple.of(name, keyType, types), k -> new TaggedChoice.TaggedChoiceType<>(k.getFirst(), (Type<K>) k.getSecond(), (Map<K, Type<?>>) k.getThird())); |
217 | 218 | }
|
218 | 219 |
|
219 | 220 | static <A, B> Type<Function<A, B>> func(final Type<A> input, final Type<B> output) {
|
@@ -461,6 +462,6 @@ final class Instances {
|
461 | 462 |
|
462 | 463 | private static final OpticFinder<Dynamic<?>> REMAINDER_FINDER = remainderType().finder();
|
463 | 464 |
|
464 |
| - private static final Map<Triple<String, Type<?>, Map<?, Type<?>>>, Type<? extends Pair<?, ?>>> TAGGED_CHOICE_TYPE_CACHE = Maps.newConcurrentMap(); |
| 465 | + private static final Map<Triple<String, Type<?>, Map<?, Type<?>>>, Type<? extends Pair<?, ?>>> TAGGED_CHOICE_TYPE_CACHE = new ConcurrentHashMap<>(); |
465 | 466 | }
|
466 | 467 | }
|
0 commit comments