Record Class RankSystem

java.lang.Object
java.lang.Record
megamek.common.universe.RankSystem
Record Components:
code - The faction rank-system code, e.g. "LAAF", "DCMS", "CLAN".
name - The display name of the rank system.
ranks - The rank rows in ascending order. Element 0 is the rank int 0, element 1 is rank int 1, and so on.

public record RankSystem(String code, String name, List<String[]> ranks) extends Record
A faction-specific rank table loaded from data/universe/ranks.xml. The index of each entry in ranks corresponds to the integer rank value stored on a person (E0 at index 0, E1 at 1, etc.) — the same scheme ratgen CommanderNode uses when it picks %CAPTAIN% / %COLONEL% for a force.

Each rankNames string is a comma-separated row of profession-specific names (None, Naval, MW, MW, MW, MW, Tech, Tech, Admin). A - placeholder means "use column 0 / the default name."

  • Constructor Details

    • RankSystem

      public RankSystem(String code, String name, List<String[]> ranks)
      Creates an instance of a RankSystem record class.
      Parameters:
      code - the value for the code record component
      name - the value for the name record component
      ranks - the value for the ranks record component
  • Method Details

    • nameAt

      @Nullable public String nameAt(int rankIndex)
      Resolves the rank int to its short display name, e.g. rank 34 in DCMS → "Tai-i". Returns null when the rank index is out of range or the row only contains placeholders.
      Parameters:
      rankIndex - The zero-based rank index stored on the person.
      Returns:
      The rank's display name, or null if no name is defined at that index.
    • 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.
    • code

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

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

      public List<String[]> ranks()
      Returns the value of the ranks record component.
      Returns:
      the value of the ranks record component