Package megamek.common.universe
Record Class FactionLeaderData
java.lang.Object
java.lang.Record
megamek.common.universe.FactionLeaderData
- Record Components:
title- the leader's title (e.g., "Duke", "Commander")firstName- the leader's given namesurname- the leader's surname; may benullhonorific- additional information following the leader's name (e.g., "III"); may benullgender- the gender of the leaderstartYear- the first year of the leader's tenure, ornullif unknownendYear- the last year of the leader's tenure, ornullif unknown
public record FactionLeaderData(String title, String firstName, String surname, String honorific, Gender gender, Integer startYear, Integer endYear)
extends Record
Stores details about a leader of a faction, including name, gender, and years of tenure.
This record encapsulates all relevant information about an individual who has led a given faction, such as their title, full name, gender, period in office, and any additional honorifics. It also provides utility methods for constructing full display titles and for validating the leader's tenure for a given year.
- Since:
- 0.50.07
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionendYear()Returns the value of theendYearrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefirstNamerecord component.gender()Returns the value of thegenderrecord component.Returns the full name of the leader, constructed from the first name and surname.getFullTitle(boolean excludeFirstOfTheirName) Constructs and returns the full formal title of the leader.final inthashCode()Returns a hash code value for this object.Returns the value of thehonorificrecord component.booleanisValidInYear(int year) Determines if this leader was in office during the specified year.Returns the value of thestartYearrecord component.surname()Returns the value of thesurnamerecord component.title()Returns the value of thetitlerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
FactionLeaderData
public FactionLeaderData(String title, String firstName, @Nullable String surname, @Nullable String honorific, Gender gender, @Nullable Integer startYear, @Nullable Integer endYear) Compact constructor that replaces anynullsurname or honorific with empty strings, and sets missing years toNO_YEAR.- Parameters:
title- the leader's titlefirstName- the leader's given namesurname- the leader's surname; may benullhonorific- additional name information; may benullgender- the leader's genderstartYear- the first year of the leader's tenure; may benullendYear- the last year of the leader's tenure; may benull- Since:
- 0.50.07
-
-
Method Details
-
getFullName
Returns the full name of the leader, constructed from the first name and surname.- Returns:
- the full name (first name and surname separated by a space)
- Since:
- 0.50.07
-
getFullTitle
Constructs and returns the full formal title of the leader.- Parameters:
excludeFirstOfTheirName- if true, omits the honorific "I" (used for the first of their name)- Returns:
- the complete title line for the leader, including honorifics
- Since:
- 0.50.07
-
isValidInYear
public boolean isValidInYear(int year) Determines if this leader was in office during the specified year.- Parameters:
year- the year to check for validity- Returns:
trueif the year is within the leader's tenure,falseotherwise- Since:
- 0.50.07
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
title
Returns the value of thetitlerecord component.- Returns:
- the value of the
titlerecord component
-
firstName
Returns the value of thefirstNamerecord component.- Returns:
- the value of the
firstNamerecord component
-
surname
Returns the value of thesurnamerecord component.- Returns:
- the value of the
surnamerecord component
-
honorific
Returns the value of thehonorificrecord component.- Returns:
- the value of the
honorificrecord component
-
gender
Returns the value of thegenderrecord component.- Returns:
- the value of the
genderrecord component
-
startYear
Returns the value of thestartYearrecord component.- Returns:
- the value of the
startYearrecord component
-
endYear
Returns the value of theendYearrecord component.- Returns:
- the value of the
endYearrecord component
-