/** * Invalidates the list as such that all {@link Transaction}s are * marked as "invalid" and will not apply post event. */ default void filterAll() { for (Transaction<BlockSnapshot> transaction: this.getTransactions()) { transaction.setValid(false); } }
/** * Applies the provided {@link Predicate} to the {@link List} of * {@link Transaction}s from {@link #getTransactions()} such that * any time that {@link Predicate#test(Object)} returns <code>false</code> * on a {@link Transaction}, the {@link Transaction} is * marked as "invalid" and will not apply post event. * * <p>{@link Transaction#getFinal()} is used to construct * the {@link ItemStack} to pass to the predicate</p> * * @param predicate The predicate to use for filtering * @return The transactions for which the predicate returned * <code>false</code> */ default List<? extends Transaction<ItemStackSnapshot>> filter(Predicate<ItemStack> predicate) { List<Transaction<ItemStackSnapshot>> invalidatedTransactions = Lists.newArrayList(); this.getTransactions().stream().filter(transaction -> !predicate.test(transaction.getFinal().createStack())).forEach(transaction -> { transaction.setValid(false); invalidatedTransactions.add(transaction); }); return invalidatedTransactions; }
/** * Applies the provided {@link Predicate} to the {@link List} of * {@link Transaction}s from {@link #getTransactions()} such that * any time that {@link Predicate#test(Object)} returns <code>false</code> * on the location of the {@link Transaction}, the {@link Transaction} is * marked as "invalid" and will not apply post event. * * <p>{@link Transaction#getOriginal()} is used to get the {@link Location}</p> * * @param predicate The predicate to use for filtering * @return The transactions for which the predicate returned * <code>false</code> */ default List<Transaction<BlockSnapshot>> filter(Predicate<Location<World>> predicate) { List<Transaction<BlockSnapshot>> invalidatedTransactions = Lists.newArrayList(); for (Transaction<BlockSnapshot> transaction: this.getTransactions()) { if (!predicate.test(transaction.getOriginal().getLocation().get())) { transaction.setValid(false); invalidatedTransactions.add(transaction); } } return invalidatedTransactions; }
/** * Invalidates the list as such that all {@link Transaction}s are * marked as "invalid" and will not apply post event. */ default void filterAll() { for (Transaction<BlockSnapshot> transaction: this.getTransactions()) { transaction.setValid(false); } }
/** * Applies the provided {@link Predicate} to the {@link List} of * {@link Transaction}s from {@link #getTransactions()} such that * any time that {@link Predicate#test(Object)} returns <code>false</code> * on a {@link Transaction}, the {@link Transaction} is * marked as "invalid" and will not apply post event. * * <p>{@link Transaction#getFinal()} is used to construct * the {@link ItemStack} to pass to the predicate</p> * * @param predicate The predicate to use for filtering * @return The transactions for which the predicate returned <code>false</code> */ default List<? extends Transaction<ItemStackSnapshot>> filter(Predicate<ItemStack> predicate) { List<Transaction<ItemStackSnapshot>> invalidatedTransactions = Lists.newArrayList(); this.getTransactions().stream().filter(transaction -> !predicate.test(transaction.getFinal().createStack())).forEach(transaction -> { transaction.setValid(false); invalidatedTransactions.add(transaction); }); return invalidatedTransactions; }
/** * Applies the provided {@link Predicate} to the {@link List} of * {@link Transaction}s from {@link #getTransactions()} such that * any time that {@link Predicate#test(Object)} returns <code>false</code> * on the location of the {@link Transaction}, the {@link Transaction} is * marked as "invalid" and will not apply post event. * * <p>{@link Transaction#getOriginal()} is used to get the {@link Location}</p> * * @param predicate The predicate to use for filtering * @return The transactions for which the predicate returned <code>false</code> */ default List<Transaction<BlockSnapshot>> filter(Predicate<Location<World>> predicate) { List<Transaction<BlockSnapshot>> invalidatedTransactions = Lists.newArrayList(); for (Transaction<BlockSnapshot> transaction: this.getTransactions()) { if (!predicate.test(transaction.getOriginal().getLocation().get())) { transaction.setValid(false); invalidatedTransactions.add(transaction); } } return invalidatedTransactions; }