Class IngredientCollectionQuantitativeGrouper<T,M,I extends IIngredientList<T,M> & IIngredientCollectionMutable<T,M>>
java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionWrapper<T,M,W>
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionMutableWrapper<T,M,I>
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionQuantitativeGrouper<T,M,I>
- Type Parameters:
T
- An instance type.M
- The matching condition parameter.I
- The inner collection type.
- All Implemented Interfaces:
Iterable<T>
,IIngredientCollapsedCollection<T,
,M> IIngredientCollapsedCollectionMutable<T,
,M> IIngredientCollection<T,
,M> IIngredientCollectionLike<T,
,M, T> IIngredientCollectionMutable<T,
M>
public class IngredientCollectionQuantitativeGrouper<T,M,I extends IIngredientList<T,M> & IIngredientCollectionMutable<T,M>>
extends IngredientCollectionMutableWrapper<T,M,I>
implements IIngredientCollapsedCollectionMutable<T,M>
A mutable ingredient collection that wraps over another mutable ingredient collection
and groups instances by stacking them using their primary quantifier.
Warning: The given collection must allow the storage of multiple equal instances such as an
IIngredientList
.
Warning: If the given collection is mutated outside of this grouper,
behaviour becomes undefined.-
Constructor Summary
ConstructorDescriptionIngredientCollectionQuantitativeGrouper
(I innerCollection) IngredientCollectionQuantitativeGrouper
(I innerCollection, boolean ignoreInnerCollectionEmptyCheck) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add the given instance to the collection.boolean
Add the given instances to the collection.boolean
Check if this collection contains the given instance.boolean
containsAll
(Iterable<? extends T> instances) Check if this collection contains all the given instances.protected IngredientComponentCategoryType<T,
M, ?> protected M
long
getQuantity
(T instance) Get the quantity of the given instance.boolean
Remove the given instance from the collection.int
Remove all the given instances from the collection.int
Remove all occurrences of the given instances under the given match conditions.int
Remove all occurrences of the given instance under the given match conditions.void
setQuantity
(T instance, long quantity) Set the quantity of the given instance.Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionMutableWrapper
clear
Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionWrapper
contains, containsAll, count, equals, getComponent, getInnerCollection, hashCode, isEmpty, iterator, iterator, size, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollection
contains, containsAll, count, iterator, parallelStream, spliterator, stream, toArray
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, size, toString
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable
clear
-
Constructor Details
-
IngredientCollectionQuantitativeGrouper
public IngredientCollectionQuantitativeGrouper(I innerCollection, boolean ignoreInnerCollectionEmptyCheck) -
IngredientCollectionQuantitativeGrouper
-
-
Method Details
-
getPrimaryQuantifier
-
getQuantifierlessMatchCondition
-
contains
Description copied from interface:IIngredientCollection
Check if this collection contains the given instance. This instance will be compared based on the matcher from the ingredient component type.- Specified by:
contains
in interfaceIIngredientCollection<T,
M> - Overrides:
contains
in classIngredientCollectionWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instance
- An instance.- Returns:
- If this collection contains the given instance.
-
containsAll
Description copied from interface:IIngredientCollection
Check if this collection contains all the given instances. The instances will be compared based on the matcher from the ingredient component type.- Specified by:
containsAll
in interfaceIIngredientCollection<T,
M> - Overrides:
containsAll
in classIngredientCollectionWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instances
- Instances.- Returns:
- If this collection contains all the given instances.
-
add
Description copied from interface:IIngredientCollectionMutable
Add the given instance to the collection.- Specified by:
add
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
add
in classIngredientCollectionMutableWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instance
- An instance.- Returns:
- If the collection was changed due to this addition. This can be false in the case of sets in which each instance can only exists once.
-
addAll
Description copied from interface:IIngredientCollectionMutable
Add the given instances to the collection.- Specified by:
addAll
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
addAll
in classIngredientCollectionMutableWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instances
- Instances.- Returns:
- If the collection was changed due to this addition. This can be false in the case of sets in which each instance can only exists once.
-
remove
Description copied from interface:IIngredientCollectionMutable
Remove the given instance from the collection.- Specified by:
remove
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
remove
in classIngredientCollectionMutableWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instance
- An instance.- Returns:
- If the collection was changed due to this addition. Can be false if the collection did not contain the instance.
-
removeAll
Description copied from interface:IIngredientCollectionMutable
Remove all occurrences of the given instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.- Specified by:
removeAll
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
removeAll
in classIngredientCollectionMutableWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- The number of removed instances.
-
removeAll
Description copied from interface:IIngredientCollectionMutable
Remove all the given instances from the collection.- Specified by:
removeAll
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
removeAll
in classIngredientCollectionMutableWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instances
- Instances.- Returns:
- The number of removed instances.
-
removeAll
Description copied from interface:IIngredientCollectionMutable
Remove all occurrences of the given instances under the given match conditions. The instances will be compared based on the matcher from the ingredient component type using the given match condition.- Specified by:
removeAll
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
removeAll
in classIngredientCollectionMutableWrapper<T,
M, I extends IIngredientList<T, M> & IIngredientCollectionMutable<T, M>> - Parameters:
instances
- Instances.matchCondition
- A match condition.- Returns:
- The number of removed instances.
-
getQuantity
Description copied from interface:IIngredientCollapsedCollectionMutable
Get the quantity of the given instance.- Specified by:
getQuantity
in interfaceIIngredientCollapsedCollectionMutable<T,
M> - Parameters:
instance
- An instance, its quantity will be ignored.- Returns:
- The quantity.
-
setQuantity
Description copied from interface:IIngredientCollapsedCollectionMutable
Set the quantity of the given instance.- Specified by:
setQuantity
in interfaceIIngredientCollapsedCollectionMutable<T,
M> - Parameters:
instance
- An instance, its quantity will be ignored.quantity
- The new quantity to set.
-