Class IngredientMapAdapter<T,M,V>

java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter<T,M,V>
Type Parameters:
T - The instance type.
M - The matching condition parameter.
V - The type of mapped values.
All Implemented Interfaces:
Iterable<Map.Entry<T,V>>, IIngredientCollectionLike<T,M,Map.Entry<T,V>>, IIngredientMap<T,M,V>, IIngredientMapMutable<T,M,V>
Direct Known Subclasses:
IngredientMapMultiClassified, IngredientMapSingleClassified, IngredientMapWrappedAdapter

public abstract class IngredientMapAdapter<T,M,V> extends Object implements IIngredientMapMutable<T,M,V>
An abstract collection that wraps instances in a IngredientInstanceWrapper and stores those in a regular Map.
  • Constructor Details

  • Method Details

    • getComponent

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

      public int removeAll(T instance, M matchCondition)
      Description copied from interface: IIngredientMapMutable
      Remove all occurrences of the given key 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 IIngredientMapMutable<T,M,V>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      The number of removed instances.
    • iterator

      public Iterator<Map.Entry<T,V>> iterator(T instance, M matchCondition)
      Description copied from interface: IIngredientCollectionLike
      An iterator over this collection over all occurrences of the given instance under the given match conditions.
      Specified by:
      iterator in interface IIngredientCollectionLike<T,M,V>
      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.
    • getAll

      public Collection<V> getAll(T key, M matchCondition)
      Description copied from interface: IIngredientMap
      Get all values for all instances that match with 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:
      getAll in interface IIngredientMap<T,M,V>
      Parameters:
      key - An instance.
      matchCondition - A match condition.
      Returns:
      All matching values.
    • keySet

      public IngredientSet<T,M> keySet(T instance, M matchCondition)
      Description copied from interface: IIngredientMap
      Get all key instances that match the given instance. This instance will be compared based on the matcher from the ingredient component type using the given match condition.
      Specified by:
      keySet in interface IIngredientMap<T,M,V>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      All key instances that match the given instance.
    • entrySet

      public Set<Map.Entry<T,V>> entrySet()
      Specified by:
      entrySet in interface IIngredientMap<T,M,V>
      Returns:
      All instance-value entries in this map.
    • 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,V>
      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.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface IIngredientCollectionLike<T,M,V>
      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,V>
      Overrides:
      toString in class Object
      Returns:
      A string representation of this collection, provided by the component type.