@SuppressWarnings("unchecked") @Override public <V, T> void forEach(final TriConsumer<String, ? super V, T> action, final T state) { iterating = true; try { for (int i = 0; i < size; i++) { action.accept(keys[i], (V) values[i], state); } } finally { iterating = false; } }
@Override public <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final S state) { final Map<String, String> map = localMap.get(); if (map == null) { return; } for (final Map.Entry<String, String> entry : map.entrySet()) { //TriConsumer should be able to handle values of any type V. In our case the values are of type String. @SuppressWarnings("unchecked") V value = (V) entry.getValue(); action.accept(entry.getKey(), value, state); } }
@SuppressWarnings("unchecked") @Override public <V, T> void forEach(final TriConsumer<String, ? super V, T> action, final T state) { iterating = true; try { for (int i = 0; i < size; i++) { action.accept(keys[i], (V) values[i], state); } } finally { iterating = false; } }
@Override public <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final S state) { final Map<String, String> map = localMap.get(); if (map == null) { return; } for (final Map.Entry<String, String> entry : map.entrySet()) { action.accept(entry.getKey(), (V) entry.getValue(), state); } }
@SuppressWarnings("unchecked") @Override public <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final S state) { final String[] keys = getSortedKeys(); for (int i = 0; i < keys.length; i++) { action.accept(keys[i], (V) map.get(keys[i]), state); } }
public static <T> T getRecipeInventoryMatch(ICraftingRecipe recipe, List<ItemStack> exactStacks, Function<ItemStack, Boolean> hasCountOrMore, IItemHandler inventory, Supplier<T> initialize, TriConsumer<T, Integer, ItemStack> onMatch, BiConsumer<T, Ingredient> onFail) { return getRecipeInventoryMatch(recipe, exactStacks, hasCountOrMore, inventory, initialize, (t, i, s) -> { onMatch.accept(t, i, s); return t; }, (t, in) -> { onFail.accept(t, in); return t; }); }