Record Class RulesRef

java.lang.Object
java.lang.Record
megamek.common.RulesRef

public record RulesRef(SourceBookCode book, Integer page) extends Record
A structured reference to one page in a sourcebook. The page is null when the source has no page reference.
  • Constructor Details

    • RulesRef

      public RulesRef(SourceBookCode book, Integer page)
      Creates an instance of a RulesRef record class.
      Parameters:
      book - the value for the book record component
      page - the value for the page record component
  • Method Details

    • toDisplayString

      public String toDisplayString()
      Returns:
      this reference formatted for display as abbrev, page, or only abbrev when its page is unknown.
    • formatForDisplay

      public static String formatForDisplay(Collection<RulesRef> references)
      Formats references for display, separated by semicolons.
    • toYamlData

      public Map<String,Object> toYamlData()
      Returns:
      serializer-independent structured export data using the sourcebook abbreviation, not the enum name.
    • toString

      public 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.
    • book

      public SourceBookCode book()
      Returns the value of the book record component.
      Returns:
      the value of the book record component
    • page

      public Integer page()
      Returns the value of the page record component.
      Returns:
      the value of the page record component