Record Class CAItem

java.lang.Object
java.lang.Record
com.io7m.cardant.model.CAItem
Record Components:
id - The item ID
name - The item name
countTotal - The item count across all storage locations in the inventory
countHere - The item count in the context of a storage location
metadata - The item metadata
attachments - The item attachments
types - The item types
All Implemented Interfaces:
CAInventoryObjectType<CAItemSummary>

public record CAItem(CAItemID id, String name, long countTotal, long countHere, SortedMap<com.io7m.lanark.core.RDottedName,CAMetadataType> metadata, SortedMap<CAAttachmentKey,CAAttachment> attachments, SortedSet<com.io7m.lanark.core.RDottedName> types) extends Record implements CAInventoryObjectType<CAItemSummary>
An item in the inventory.
  • Constructor Details

    • CAItem

      public CAItem(CAItemID id, String name, long countTotal, long countHere, SortedMap<com.io7m.lanark.core.RDottedName,CAMetadataType> metadata, SortedMap<CAAttachmentKey,CAAttachment> attachments, SortedSet<com.io7m.lanark.core.RDottedName> types)
      Construct an item.
      Parameters:
      id - The item ID
      name - The item name
      countTotal - The item count
      countHere - The item count in the context of a storage location
      metadata - The item metadata
      attachments - The item attachments
      types - The types assigned to the item
  • Method Details

    • create

      public static CAItem create()
      Create an empty item with a pseudorandom ID.
      Returns:
      The item
    • withCountHere

      public CAItem withCountHere(long newCountHere)
      Set the count in the current storage location context for this item.
      Parameters:
      newCountHere - The item count
      Returns:
      This item with the given count
    • summary

      public CAItemSummary summary()
      Specified by:
      summary in interface CAInventoryObjectType<CAItemSummary>
      Returns:
      A summary of the object
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public CAItemID id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • countTotal

      public long countTotal()
      Returns the value of the countTotal record component.
      Returns:
      the value of the countTotal record component
    • countHere

      public long countHere()
      Returns the value of the countHere record component.
      Returns:
      the value of the countHere record component
    • metadata

      public SortedMap<com.io7m.lanark.core.RDottedName,CAMetadataType> metadata()
      Returns the value of the metadata record component.
      Specified by:
      metadata in interface CAInventoryObjectType<CAItemSummary>
      Returns:
      the value of the metadata record component
    • attachments

      public SortedMap<CAAttachmentKey,CAAttachment> attachments()
      Returns the value of the attachments record component.
      Specified by:
      attachments in interface CAInventoryObjectType<CAItemSummary>
      Returns:
      the value of the attachments record component
    • types

      public SortedSet<com.io7m.lanark.core.RDottedName> types()
      Returns the value of the types record component.
      Specified by:
      types in interface CAInventoryObjectType<CAItemSummary>
      Returns:
      the value of the types record component