Class IngredientComponentStorageWrapped<T,M>

java.lang.Object
org.cyclops.cyclopscore.ingredient.storage.IngredientComponentStorageWrapped<T,M>
Type Parameters:
T - The instance type.
M - The matching condition parameter.
All Implemented Interfaces:
Iterable<T>, IIngredientComponentStorage<T,M>
Direct Known Subclasses:
IngredientComponentStorageSlottedWrapped

public class IngredientComponentStorageWrapped<T,M> extends Object implements IIngredientComponentStorage<T,M>
An ingredient storage wrapper.
  • Constructor Details

    • IngredientComponentStorageWrapped

      public IngredientComponentStorageWrapped(IIngredientComponentStorage<T,M> ingredientComponentStorage, boolean read, boolean insert, boolean extract)
  • Method Details

    • getIngredientComponentStorage

      protected IIngredientComponentStorage<T,M> getIngredientComponentStorage()
    • isRead

      protected boolean isRead()
    • isInsert

      protected boolean isInsert()
    • isExtract

      protected boolean isExtract()
    • getComponent

      public IngredientComponent<T,M> getComponent()
      Specified by:
      getComponent in interface IIngredientComponentStorage<T,M>
      Returns:
      The ingredient component type this storage applies to.
    • iterator

      public Iterator<T> iterator()
      Description copied from interface: IIngredientComponentStorage
      Get all ingredients in this storage.
      Specified by:
      iterator in interface IIngredientComponentStorage<T,M>
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      An iterator over all available ingredients in this storage.
    • iterator

      public Iterator<T> iterator(@Nonnull T prototype, M matchCondition)
      Description copied from interface: IIngredientComponentStorage
      Find all ingredients matching the given prototype from the storage. Calling this method will not modify the storage in any way. Results from this method MUST NOT be modified.
      Specified by:
      iterator in interface IIngredientComponentStorage<T,M>
      Parameters:
      prototype - The ingredient to search for.
      matchCondition - The flags to compare the given prototype by according to IngredientComponent.getMatcher().
      Returns:
      An iterator over ingredients that match the given prototype, which may potentially be empty.
    • getMaxQuantity

      public long getMaxQuantity()
      Specified by:
      getMaxQuantity in interface IIngredientComponentStorage<T,M>
      Returns:
      The maximum allowed quantity over all instances.
    • insert

      public T insert(@Nonnull T ingredient, boolean simulate)
      Description copied from interface: IIngredientComponentStorage
      Inserts an ingredient into the storage and return the remainder. The ingredient should not be modified in this function!
      Specified by:
      insert in interface IIngredientComponentStorage<T,M>
      Parameters:
      ingredient - Ingredient to insert.
      simulate - If true, the insertion is only simulated.
      Returns:
      The remaining ingredient that was not inserted (if the entire ingredient is accepted, then return IIngredientMatcher.getEmptyInstance()). May be the same as the input ingredient if unchanged, otherwise a new ingredient.
    • extract

      public T extract(@Nonnull T prototype, M matchCondition, boolean simulate)
      Description copied from interface: IIngredientComponentStorage
      Extract an ingredient matching the given prototype from the storage. Note that only the extracted ingredient must match the prototype under the given condition. Internally, ingredients can be combined and matched in any way. For example, an exact match could be produced by combining several ingredients. If the primary quantifier (as identified by IngredientComponent.getPrimaryQuantifier()) IS NOT part of the match condition, then the quantity of the given prototype MUST be interpreted as the maximum quantity that must be extracted. If the primary quantifier (as identified by IngredientComponent.getPrimaryQuantifier()) IS part of the match condition, then the quantity of the given prototype MUST be interpreted as the exact quantity that must be extracted. If the storage has a HIGHER OR EQUAL available quantity, then the storage MUST allow the given quantity to be extracted. If the storage on the other hand has a LOWER available quantity, then extraction is not allowed.
      Specified by:
      extract in interface IIngredientComponentStorage<T,M>
      Parameters:
      prototype - The ingredient to search for.
      matchCondition - The flags to compare the given prototype by according to IngredientComponent.getMatcher().
      simulate - If true, the insertion is only simulated
      Returns:
      Ingredient extracted from the slot, must be IIngredientMatcher.getEmptyInstance(), if nothing can be extracted
    • extract

      public T extract(long maxQuantity, boolean simulate)
      Description copied from interface: IIngredientComponentStorage
      Extract any ingredient, but the given maximum amount from the storage.
      Specified by:
      extract in interface IIngredientComponentStorage<T,M>
      Parameters:
      maxQuantity - The maximum amount to extract.
      simulate - If true, the insertion is only simulated
      Returns:
      Ingredient extracted from the slot, must be IIngredientMatcher.getEmptyInstance(), if nothing can be extracted