Search in sources :

Example 1 with MultiInventoryAdapter

use of org.spongepowered.common.inventory.adapter.impl.MultiInventoryAdapter in project SpongeCommon by SpongePowered.

the class AppendQuery method execute.

@Override
public Inventory execute(Inventory inventory, InventoryAdapter adapter) {
    Inventory result = new EmptyInventoryImpl(inventory);
    if (this.queryList.isEmpty()) {
        return result;
    }
    List<Inventory> results = this.queryList.stream().map(q -> q.execute(inventory)).collect(Collectors.toList());
    return new MultiInventoryAdapter(results);
}
Also used : Inventory(org.spongepowered.api.item.inventory.Inventory) SpongeQuery(org.spongepowered.common.inventory.query.SpongeQuery) Query(org.spongepowered.api.item.inventory.query.Query) Arrays(java.util.Arrays) List(java.util.List) MultiInventoryAdapter(org.spongepowered.common.inventory.adapter.impl.MultiInventoryAdapter) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) EmptyInventoryImpl(org.spongepowered.common.inventory.EmptyInventoryImpl) InventoryAdapter(org.spongepowered.common.inventory.adapter.InventoryAdapter) ArrayList(java.util.ArrayList) EmptyInventoryImpl(org.spongepowered.common.inventory.EmptyInventoryImpl) MultiInventoryAdapter(org.spongepowered.common.inventory.adapter.impl.MultiInventoryAdapter) Inventory(org.spongepowered.api.item.inventory.Inventory)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inventory (org.spongepowered.api.item.inventory.Inventory)1 Query (org.spongepowered.api.item.inventory.query.Query)1 EmptyInventoryImpl (org.spongepowered.common.inventory.EmptyInventoryImpl)1 InventoryAdapter (org.spongepowered.common.inventory.adapter.InventoryAdapter)1 MultiInventoryAdapter (org.spongepowered.common.inventory.adapter.impl.MultiInventoryAdapter)1 SpongeQuery (org.spongepowered.common.inventory.query.SpongeQuery)1