java.lang.Object
org.holiday.calendar.util.CsvObservanceLoader
Utility for loading observance date tables from classpath CSV resources.
CSV format: year,YYYY-MM-DD[,comment]. Lines that are blank or
start with # (after stripping leading/trailing whitespace) are
ignored. Malformed data rows (unparseable year or date, fewer than two
fields) are logged at WARN level and skipped; valid rows in the same file
are still loaded.
Both methods accept a Class<?> anchor whose
Class.getResourceAsStream(java.lang.String) is used to locate the resource. This
follows JPMS resource-access semantics: pass the class that lives in the
same module package as the resource file.
This class is stateless and thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionloadMultiple(Class<?> anchor, String classpathResource) Loads a CSV where each year may map to multiple dates (insertion order preserved within each year's list).loadSingle(Class<?> anchor, String classpathResource) Loads a CSV where each year maps to exactly one date.
-
Method Details
-
loadSingle
Loads a CSV where each year maps to exactly one date.If the same year appears more than once, the last row wins (standard
HashMapput semantics).- Parameters:
anchor- class used to resolve the classpath resourceclasspathResource- resource path, relative toanchor's package or absolute (starting with/)- Returns:
- unmodifiable
Map<Integer, LocalDate>, preserving CSV order - Throws:
IllegalStateException- if the resource is not found on the classpathExceptionInInitializerError- wrappingIOExceptionon read failure
-
loadMultiple
Loads a CSV where each year may map to multiple dates (insertion order preserved within each year's list).- Parameters:
anchor- class used to resolve the classpath resourceclasspathResource- resource path, relative toanchor's package or absolute (starting with/)- Returns:
- unmodifiable
Map<Integer, List<LocalDate>>with unmodifiable value lists - Throws:
IllegalStateException- if the resource is not found on the classpathExceptionInInitializerError- wrappingIOExceptionon read failure
-