Package megamek.common.eras
Class Eras
java.lang.Object
megamek.common.eras.Eras
This singleton class is a handler for the Eras of the BT Universe like the
Civil War or the
Succession Wars. The Eras are read from the eras.xml definition file and are
thus moddable.
The class therefore has a few methods that deal with validation and is
supposed to be
resistant to wrong data.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Era
getEra
(int year) Returns theEra
of the first day of the given year (January 1st).static Era
Returns theEra
of the given date.getEras()
Returns a list of all Eras, ordered by their end dates, i.e.static Eras
static boolean
isFirstEra
(Era era) static boolean
Returns true when the given date is in the given Era.static Era
static Era
previousEra
(Era era) static LocalDate
-
Method Details
-
getInstance
- Returns:
- The sole instance of Eras. Calling this also initialises and loads the eras.
-
getEra
Returns theEra
of the given date. For the canon eras the day makes no difference but the eras definition xml allows eras to be defined with day resolution.- Parameters:
date
- The date to get the Era for- Returns:
- The Era of the given date, e.g. IlClan on March 25, 3153
-
getEra
Returns theEra
of the first day of the given year (January 1st). For the canon eras the day makes no difference but the eras definition xml allows eras to be defined with day resolution. Therefore it is preferable to usegetEra(LocalDate)
when a date is available.- Parameters:
year
- The year to get the Era for- Returns:
- The Era on January 1st of the given year
-
isThisEra
Returns true when the given date is in the given Era.- Parameters:
date
- The date to testera
- The Era to check against the date- Returns:
- True when the date is in the Era's date range
-
getEras
Returns a list of all Eras, ordered by their end dates, i.e. in their natural order with the oldest being first.- Returns:
- All Eras
-
isFirstEra
- Returns:
- True if the given Era is the first (earliest) of all eras.
-
previousEra
- Returns:
- The era directly preceding the given Era, if any, null if the given Era is the first era (or null).
-
nextEra
- Returns:
- The era directly following the given Era, if any, null if the given Era is the last era (or null).
-
startDate
- Returns:
- The starting date of the given Era or LocalDate.MIN if the given Era is the first era.
-