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 benull
honorific
- additional information following the leader's name (e.g., "III"); may benull
gender
- the gender of the leaderstartYear
- the first year of the leader's tenure, ornull
if unknownendYear
- the last year of the leader's tenure, ornull
if 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 theendYear
record component.final boolean
Indicates whether some other object is "equal to" this one.Returns the value of thefirstName
record component.gender()
Returns the value of thegender
record 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 int
hashCode()
Returns a hash code value for this object.Returns the value of thehonorific
record component.boolean
isValidInYear
(int year) Determines if this leader was in office during the specified year.Returns the value of thestartYear
record component.surname()
Returns the value of thesurname
record component.title()
Returns the value of thetitle
record component.final String
toString()
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 anynull
surname 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 benull
honorific
- additional name information; may benull
gender
- the leader's genderstartYear
- the first year of the leader's tenure; may benull
endYear
- 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:
true
if the year is within the leader's tenure,false
otherwise- 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 thetitle
record component.- Returns:
- the value of the
title
record component
-
firstName
Returns the value of thefirstName
record component.- Returns:
- the value of the
firstName
record component
-
surname
Returns the value of thesurname
record component.- Returns:
- the value of the
surname
record component
-
honorific
Returns the value of thehonorific
record component.- Returns:
- the value of the
honorific
record component
-
gender
Returns the value of thegender
record component.- Returns:
- the value of the
gender
record component
-
startYear
Returns the value of thestartYear
record component.- Returns:
- the value of the
startYear
record component
-
endYear
Returns the value of theendYear
record component.- Returns:
- the value of the
endYear
record component
-