Class IngredientCollectionAdapter<T,M>

java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter<T,M>
Type Parameters:
T - The instance type.
M - The matching condition parameter.
All Implemented Interfaces:
Iterable<T>, IIngredientCollection<T,M>, IIngredientCollectionLike<T,M,T>, IIngredientCollectionMutable<T,M>
Direct Known Subclasses:
IngredientCollectionCollectionAdapter, IngredientCollectionCollectionWrappedAdapter, IngredientCollectionMultiClassified, IngredientCollectionPrototypeMap, IngredientCollectionSingleClassified

public abstract class IngredientCollectionAdapter<T,M> extends Object implements IIngredientCollectionMutable<T,M>
An adapter class for mutable ingredient collections.
  • Constructor Details

  • Method Details

    • getComponent

      public IngredientComponent<T,M> getComponent()
      Specified by:
      getComponent in interface IIngredientCollectionLike<T,M,T>
      Returns:
      The ingredient component type of which this collection contains instances.
    • remove

      public boolean remove(T instance)
      Description copied from interface: IIngredientCollectionMutable
      Remove the given instance from the collection.
      Specified by:
      remove in interface 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

      public int removeAll(T instance, M matchCondition)
      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 interface IIngredientCollectionMutable<T,M>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      The number of removed instances.
    • contains

      public boolean contains(T instance)
      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 interface IIngredientCollection<T,M>
      Parameters:
      instance - An instance.
      Returns:
      If this collection contains the given instance.
    • contains

      public boolean contains(T instance, M matchCondition)
      Description copied from interface: IIngredientCollection
      Check if this collection contains 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:
      contains in interface IIngredientCollection<T,M>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      If this collection contains the given instance under the given match conditions.
    • count

      public int count(T instance, M matchCondition)
      Description copied from interface: IIngredientCollection
      Count the number of 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:
      count in interface IIngredientCollection<T,M>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      The number of occurrences of the given instance under the given match conditions.
    • iterator

      public Iterator<T> iterator(T instance, M matchCondition)
      Description copied from interface: IIngredientCollection
      An iterator over this collection over all occurrences of the given instance under the given match conditions.
      Specified by:
      iterator in interface IIngredientCollection<T,M>
      Specified by:
      iterator in interface IIngredientCollectionLike<T,M,T>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      An iterator over this collection over all occurrences of the given instance under the given match conditions.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface IIngredientCollectionLike<T,M,T>
      Overrides:
      hashCode in class Object
      Returns:
      A hashcode of this collection, based on the hash codes, provided by the component type.
    • toString

      public String toString()
      Specified by:
      toString in interface IIngredientCollectionLike<T,M,T>
      Overrides:
      toString in class Object
      Returns:
      A string representation of this collection, provided by the component type.