Class IngredientCollectionSingleClassifiedCollapsed<T,M,C>
java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter<T,M>
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionSingleClassified<T,M,C,IIngredientCollapsedCollectionMutable<T,M>>
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionSingleClassifiedCollapsed<T,M,C>
- All Implemented Interfaces:
Iterable<T>
,IIngredientCollapsedCollection<T,
,M> IIngredientCollapsedCollectionMutable<T,
,M> IIngredientCollection<T,
,M> IIngredientCollectionLike<T,
,M, T> IIngredientCollectionLikeSingleClassifiedTrait<T,
,M, T, C, IIngredientCollapsedCollectionMutable<T, M>> IIngredientCollectionMutable<T,
M>
public class IngredientCollectionSingleClassifiedCollapsed<T,M,C>
extends IngredientCollectionSingleClassified<T,M,C,IIngredientCollapsedCollectionMutable<T,M>>
implements IIngredientCollapsedCollectionMutable<T,M>
An ingredient collection that classifies instances in smaller collections based on a category type,
but multiple instances that are equal (ignoring quantity) are collapsed into one.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeSingleClassifiedTrait
IIngredientCollectionLikeSingleClassifiedTrait.ClassifiedIterator<T,
M, I, C, L extends IIngredientCollectionLike<T, M, I>>, IIngredientCollectionLikeSingleClassifiedTrait.ClassifiedIteratorDelegated<T, M, C, I, L extends IIngredientCollectionLike<T, M, I>> -
Constructor Summary
ConstructorDescriptionIngredientCollectionSingleClassifiedCollapsed
(IngredientComponent<T, M> component, Supplier<IIngredientCollapsedCollectionMutable<T, M>> collectionCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionlong
getQuantity
(T instance) Get the quantity of the given instance.void
setQuantity
(T instance, long quantity) Set the quantity of the given instance.int
size()
Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionSingleClassified
add, clear, contains, contains, count, createEmptyCollection, equals, getCategoryType, getClassifiedCollections, getInstance, iterator, iterator, remove, removeAll, setSize
Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter
getComponent, hashCode, 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, contains, containsAll, containsAll, count, iterator, parallelStream, spliterator, stream, toArray
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, toString
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeSingleClassifiedTrait
appliesToClassifier, getClassifier, getOrCreateClassifiedCollection
-
Constructor Details
-
IngredientCollectionSingleClassifiedCollapsed
public IngredientCollectionSingleClassifiedCollapsed(IngredientComponent<T, M> component, Supplier<IIngredientCollapsedCollectionMutable<T, M>> collectionCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance.- Parameters:
component
- A component type.collectionCreator
- A callback for creating new internal collections for a single classifier.categoryType
- A category type using which this collection will classify instance.
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceIIngredientCollectionLike<T,
M, C> - Overrides:
size
in classIngredientCollectionSingleClassified<T,
M, C, IIngredientCollapsedCollectionMutable<T, M>> - Returns:
- The number of instances contained in this collection.
-
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.
-