Class IngredientCollectionWrapper<T,M,W extends IIngredientCollection<T,M>>

java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionWrapper<T,M,W>
Type Parameters:
T - An instance type.
M - The matching condition parameter.
All Implemented Interfaces:
Iterable<T>, IIngredientCollection<T,M>, IIngredientCollectionLike<T,M,T>
Direct Known Subclasses:
IngredientCollectionMutableWrapper

public class IngredientCollectionWrapper<T,M,W extends IIngredientCollection<T,M>> extends Object implements IIngredientCollection<T,M>
An ingredient collection that wraps over another ingredient collection.
  • Constructor Details

    • IngredientCollectionWrapper

      public IngredientCollectionWrapper(W innerCollection)
  • Method Details

    • getInnerCollection

      protected W getInnerCollection()
    • 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.
    • containsAll

      public boolean containsAll(Iterable<? extends T> instances)
      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 interface IIngredientCollection<T,M>
      Parameters:
      instances - Instances.
      Returns:
      If this collection contains all the given instances.
    • containsAll

      public boolean containsAll(Iterable<? extends T> instances, M matchCondition)
      Description copied from interface: IIngredientCollection
      Check if this collection contains all 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:
      containsAll in interface IIngredientCollection<T,M>
      Parameters:
      instances - Instances.
      matchCondition - A match condition.
      Returns:
      If this collection contains all the given instances 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.
    • getComponent

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

      public int size()
      Specified by:
      size in interface IIngredientCollectionLike<T,M,W extends IIngredientCollection<T,M>>
      Returns:
      The number of instances contained in this collection.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IIngredientCollectionLike<T,M,W extends IIngredientCollection<T,M>>
      Returns:
      If the are no instances in this collection.
    • 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,W extends IIngredientCollection<T,M>>
      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.
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • hashCode

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

      public boolean equals(Object obj)
      Description copied from interface: IIngredientCollectionLike
      Check if this collection equals the given object.
      Specified by:
      equals in interface IIngredientCollectionLike<T,M,W extends IIngredientCollection<T,M>>
      Overrides:
      equals in class Object
      Parameters:
      obj - An object.
      Returns:
      True if the given object is an ingredient collection of the same type, component type and contains the same instances.
    • toString

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