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
ConstructorsConstructorDescriptionIngredientCollectionSingleClassifiedCollapsed(IngredientComponent<T, M> component, Supplier<IIngredientCollapsedCollectionMutable<T, M>> collectionCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionlonggetQuantity(T instance) Get the quantity of the given instance.voidsetQuantity(T instance, long quantity) Set the quantity of the given instance.intsize()Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionSingleClassified
add, clear, contains, contains, count, createEmptyCollection, equals, getCategoryType, getClassifiedCollections, getInstance, iterator, iterator, remove, removeAll, setSizeMethods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter
getComponent, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollection
contains, contains, containsAll, containsAll, count, iterator, parallelStream, spliterator, stream, toArrayMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, toStringMethods 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:
sizein interfaceIIngredientCollectionLike<T,M, C> - Overrides:
sizein classIngredientCollectionSingleClassified<T,M, C, IIngredientCollapsedCollectionMutable<T, M>> - Returns:
- The number of instances contained in this collection.
-
getQuantity
Description copied from interface:IIngredientCollapsedCollectionMutableGet the quantity of the given instance.- Specified by:
getQuantityin interfaceIIngredientCollapsedCollectionMutable<T,M> - Parameters:
instance- An instance, its quantity will be ignored.- Returns:
- The quantity.
-
setQuantity
Description copied from interface:IIngredientCollapsedCollectionMutableSet the quantity of the given instance.- Specified by:
setQuantityin interfaceIIngredientCollapsedCollectionMutable<T,M> - Parameters:
instance- An instance, its quantity will be ignored.quantity- The new quantity to set.
-