Class warehouse

java.lang.Object
name.moore.kevin.ze.game.warehouse

public class warehouse extends Object
Any planet with manufacturing facilities will deliver manufactured equipment into a planet-wide/orbit-wide warehouse.

Items can be added to the warehouse to increase stock, they can be reserved for use (and effectively reducing stock) or finally checkedout for usage.

The expected pattern is :

  • add parts to the warehouse .put(S,A);
  • check if in stock if( .isInStock(S) )
  • reserve it .reserve(S);
  • use it .checkout(S);
Author:
Kevin Moore <dev@kevin.moore.name>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private com.google.common.collect.ListMultimap<com.simsilica.es.EntityId,​com.simsilica.es.EntityId>
    Map of spec entityid ->List[manufactured parts having this spec].
    private static org.slf4j.Logger
     
    private com.google.common.collect.ListMultimap<com.simsilica.es.EntityId,​com.simsilica.es.EntityId>
    Parts in this list are reserved for specific build tickets.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Map<com.simsilica.es.EntityId,​com.simsilica.es.EntityId>
    checkout​(com.simsilica.es.EntityId spec)
    Checkout an item in the order (of specs) from the warehouse so we can use them for eg installation where they become assigned to a build ticket.
    Map<com.simsilica.es.EntityId,​Integer>
     
    Map<com.simsilica.es.EntityId,​Integer>
     
    boolean
    isInStock​(com.simsilica.es.EntityId spec)
    Warehouse contains at least one built item of the required specification available and in stock.
    boolean
    isReserved​(com.simsilica.es.EntityId spec)
    Do we have a part of the spec under reservation? This doesn't differentiate if a particular ticket has the reservation, just that someone has.
    void
    put​(com.simsilica.es.EntityId spec, com.simsilica.es.EntityId item)
    It is an assumption that only valid items are are stored in the warehouse, so no planets or stars!
    com.simsilica.es.EntityId
    reserve​(com.simsilica.es.EntityId spec)
    If we have an item in stock, reserve it and reduce stock levels.
    This will be a dump of the map {a=b,c=d}

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • instock

      private com.google.common.collect.ListMultimap<com.simsilica.es.EntityId,​com.simsilica.es.EntityId> instock
      Map of spec entityid ->List[manufactured parts having this spec]. parts in this list are on the shelf and ready to be used.
    • reserved

      private com.google.common.collect.ListMultimap<com.simsilica.es.EntityId,​com.simsilica.es.EntityId> reserved
      Parts in this list are reserved for specific build tickets. Multiple parts having the same spec may be reserved. Spec ->List[parts]
  • Constructor Details

    • warehouse

      public warehouse()
  • Method Details

    • put

      public void put(com.simsilica.es.EntityId spec, com.simsilica.es.EntityId item)
      It is an assumption that only valid items are are stored in the warehouse, so no planets or stars!

      Increases the stock level

      Parameters:
      spec -
      item -
    • getStockLevels

      public Map<com.simsilica.es.EntityId,​Integer> getStockLevels()
      Returns:
    • getReservedLevels

      public Map<com.simsilica.es.EntityId,​Integer> getReservedLevels()
      Returns:
    • isInStock

      public boolean isInStock(com.simsilica.es.EntityId spec)
      Warehouse contains at least one built item of the required specification available and in stock.
      Returns:
      true if there is at least one item of the required spec available ie not yet reserved.
    • isReserved

      public boolean isReserved(com.simsilica.es.EntityId spec)
      Do we have a part of the spec under reservation? This doesn't differentiate if a particular ticket has the reservation, just that someone has.
      Parameters:
      spec -
      Returns:
    • reserve

      public com.simsilica.es.EntityId reserve(com.simsilica.es.EntityId spec)
      If we have an item in stock, reserve it and reduce stock levels.
      Parameters:
      spec -
      Returns:
      reserved part
    • checkout

      public Map<com.simsilica.es.EntityId,​com.simsilica.es.EntityId> checkout(com.simsilica.es.EntityId spec)
      Checkout an item in the order (of specs) from the warehouse so we can use them for eg installation where they become assigned to a build ticket.

      It is assumed the requested items are available, so check before asking. If they are not, the return is an empty Map. Items are removed from the warehouse and stock levels reduced.

      Parameters:
      spec - part with this spec is requested
      Returns:
      spec ->part
    • toString

      public String toString()
      This will be a dump of the map {a=b,c=d}
      Overrides:
      toString in class Object
      Returns: