Record Class FoodFactsV2

java.lang.Object
java.lang.Record
ke.ric.api.food.FoodFactsV2
Record Components:
itemId - source-qualified identity of this food, or null for empty/air items
ingredientIds - immutable set of observed source-qualified ingredient IDs
categories - immutable set of uppercase dietary categories (e.g., PLANT, MEAT, DAIRY, ALCOHOL)
tags - immutable set of normalized uppercase custom tags
dietaryFacts - immutable map of dietary flags (e.g., VEGAN, VEGETARIAN, PORK_FREE, ALCOHOL_FREE) to FoodFactsV2.Truth
complete - true if every contributing ingredient lineage is known
categoriesComplete - true if every known ingredient's category classification is complete

public record FoodFactsV2(String itemId, Set<String> ingredientIds, Set<String> categories, Set<String> tags, Map<String, FoodFactsV2.Truth> dietaryFacts, boolean complete, boolean categoriesComplete) extends Record
Immutable, source-qualified evidence about one food. Ingredient completeness and category completeness are separate: neither is a certification of the food. Reads are observational and never reconstruct historical custom recipes.

Identities use source-qualified keys (heirloom:<id>, minecraft:<material>, or <provider>:<item>). Check complete() and categoriesComplete() before treating FoodFactsV2.Truth.UNKNOWN or FoodFactsV2.Truth.TRUE as conclusive.

  • Constructor Details

    • FoodFactsV2

      public FoodFactsV2(String itemId, Set<String> ingredientIds, Set<String> categories, Set<String> tags, Map<String, FoodFactsV2.Truth> dietaryFacts, boolean complete, boolean categoriesComplete)
      Creates an instance of a FoodFactsV2 record class.
      Parameters:
      itemId - the value for the itemId record component
      ingredientIds - the value for the ingredientIds record component
      categories - the value for the categories record component
      tags - the value for the tags record component
      dietaryFacts - the value for the dietaryFacts record component
      complete - the value for the complete record component
      categoriesComplete - the value for the categoriesComplete record component
  • Method Details

    • read

      public static FoodFactsV2 read(org.bukkit.inventory.ItemStack item)
      Read current V2 evidence or a conservative view of legacy metadata. Does not write.
    • write

      public static void write(org.bukkit.inventory.ItemStack item, FoodFactsV2 facts)
      Write only the V2 key. Positive alcohol metadata on the actual stack always wins.
    • produced

      public static FoodFactsV2 produced(FoodFactsV2 result, Collection<FoodFactsV2> inputs)
      Combine actual consumed inputs with explicitly supplied result evidence. The caller must not pass a synthetic vanilla output recipe as result evidence. Every input is consumed, even when its identity matches the output. Use read/write directly for identity-preserving copies instead of this merger.
    • writeProduced

      public static void writeProduced(org.bukkit.inventory.ItemStack output, List<org.bukkit.inventory.ItemStack> actualInputs, String explicitQualifiedOutputId)
      Record a production boundary from its actual stacks. A qualified declaration supplies an output identity only when the stack has no actual custom owner. Read inputs before mutating the output so an in-place operation is supported.
    • 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.
    • itemId

      public String itemId()
      Returns the value of the itemId record component.
      Returns:
      the value of the itemId record component
    • ingredientIds

      public Set<String> ingredientIds()
      Returns the value of the ingredientIds record component.
      Returns:
      the value of the ingredientIds record component
    • categories

      public Set<String> categories()
      Returns the value of the categories record component.
      Returns:
      the value of the categories record component
    • tags

      public Set<String> tags()
      Returns the value of the tags record component.
      Returns:
      the value of the tags record component
    • dietaryFacts

      public Map<String, FoodFactsV2.Truth> dietaryFacts()
      Returns the value of the dietaryFacts record component.
      Returns:
      the value of the dietaryFacts record component
    • complete

      public boolean complete()
      Returns the value of the complete record component.
      Returns:
      the value of the complete record component
    • categoriesComplete

      public boolean categoriesComplete()
      Returns the value of the categoriesComplete record component.
      Returns:
      the value of the categoriesComplete record component