Record Class StorageDefinition

java.lang.Object
java.lang.Record
fr.robie.machineengine.api.machine.StorageDefinition
Record Components:
id - unique within the machine type, e.g. input
capacityModifier - scales each slot's capacity with the machine's upgrades (e.g. Mekanism's energy upgrade enlarging the energy buffer), or null

public record StorageDefinition(@NotNull String id, int slots, long capacity, @NotNull ResourcePredicate filter, @Nullable ModifierType capacityModifier) extends Record
A storage of a machine type: slots slots of capacity each, accepting variants matching filter (ARCHITECTURE.md ยง12). The engine creates and persists it.
  • Constructor Details

    • StorageDefinition

      public StorageDefinition(@NotNull @NotNull String id, int slots, long capacity, @NotNull @NotNull ResourcePredicate filter, @Nullable @Nullable ModifierType capacityModifier)
      Creates an instance of a StorageDefinition record class.
      Parameters:
      id - the value for the id record component
      slots - the value for the slots record component
      capacity - the value for the capacity record component
      filter - the value for the filter record component
      capacityModifier - the value for the capacityModifier record component
    • StorageDefinition

      public StorageDefinition(@NotNull @NotNull String id, int slots, long capacity, @NotNull @NotNull ResourcePredicate filter)
  • Method Details

    • capacityModifier

      @NotNull public @NotNull StorageDefinition capacityModifier(@NotNull @NotNull ModifierType modifier)
      Each slot's capacity follows modifier (applied to capacity() with the machine's upgrades).
    • slots

      @NotNull public static @NotNull StorageDefinition slots(@NotNull @NotNull String id, int count, long capacity)
      count slots of capacity each, accepting anything.
    • tank

      @NotNull public static @NotNull StorageDefinition tank(@NotNull @NotNull String id, long capacity)
      A single slot, e.g. a tank or battery.
    • filter

      @NotNull public @NotNull StorageDefinition filter(@NotNull @NotNull ResourcePredicate filter)
    • 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 the compare method from their corresponding wrapper classes.
      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

      @NotNull public @NotNull String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • slots

      public int slots()
      Returns the value of the slots record component.
      Returns:
      the value of the slots record component
    • capacity

      public long capacity()
      Returns the value of the capacity record component.
      Returns:
      the value of the capacity record component
    • filter

      @NotNull public @NotNull ResourcePredicate filter()
      Returns the value of the filter record component.
      Returns:
      the value of the filter record component
    • capacityModifier

      @Nullable public @Nullable ModifierType capacityModifier()
      Returns the value of the capacityModifier record component.
      Returns:
      the value of the capacityModifier record component