Record Class BlockSpec

java.lang.Object
java.lang.Record
nl.pim16aap2.lightkeeper.framework.BlockSpec
Record Components:
materialKey - Canonical namespaced material key, e.g. minecraft:lever.
properties - The state properties this spec names, in insertion order.

public record BlockSpec(String materialKey, Map<String,String> properties) extends Record
A block specification: a material plus the state properties a test cares about.

Specs are partial by design: only the named properties participate in matching (see BlockStateSnapshot.matches(BlockSpec)), so a lever test can assert powered=true without enumerating face and facing defaults.

  • Constructor Details

    • BlockSpec

      public BlockSpec(String materialKey, Map<String,String> properties)
      Validates and normalizes the fields.
  • Method Details

    • of

      public static BlockSpec of(org.bukkit.Material material)
      Creates a spec for a material with no state properties.
      Parameters:
      material - The material.
      Returns:
      The spec.
    • of

      public static BlockSpec of(String materialKey)
      Creates a spec for a material key with no state properties.
      Parameters:
      materialKey - Material key, e.g. STONE or minecraft:stone.
      Returns:
      The spec.
    • parse

      public static BlockSpec parse(String blockData)
      Parses a block-data style string into a spec.
      Parameters:
      blockData - A string like minecraft:lever[powered=true,facing=north]; the bracket section is optional.
      Returns:
      The parsed spec.
      Throws:
      IllegalArgumentException - If the string is malformed.
    • with

      public BlockSpec with(String property, String value)
      Returns a copy of this spec with one property set.
      Parameters:
      property - The property name.
      value - The property value.
      Returns:
      A new spec with the property applied.
    • asString

      public String asString()
      Renders this spec in block-data string form.
      Returns:
      E.g. minecraft:lever[powered=true]; just the material key when no properties are named.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • materialKey

      public String materialKey()
      Returns the value of the materialKey record component.
      Returns:
      the value of the materialKey record component
    • properties

      public Map<String,String> properties()
      Returns the value of the properties record component.
      Returns:
      the value of the properties record component