Class CountrySpecificDefaultUtils


  • public class CountrySpecificDefaultUtils
    extends Object
    Class with some common functionality for defaults that are country specific and stored in CSV files
    Author:
    markr
    • Constructor Detail

      • CountrySpecificDefaultUtils

        public CountrySpecificDefaultUtils()
    • Method Detail

      • callForEachFileInResourceDir

        public static void callForEachFileInResourceDir​(String resourceDir,
                                                        BiConsumer<InputStreamReader,​String> callBack)
        Call consumer for each country specific file in resource dir
        Parameters:
        resourceDir - to use
        callBack - to use
      • extractCountryNameFromFile

        public static String extractCountryNameFromFile​(Path filePath)
                                                 throws PlanItException
        Validate if file is a valid resource file and its name is constructed based on a country code. Each file should be named according to ISO366 alpha 2 country code. If valid the full country name is returned
        Parameters:
        filePath - to validate
        Returns:
        full country name, otherwise null
        Throws:
        PlanItException - thrown if error
      • collectCsvRecordIterable

        public static Iterable<org.apache.commons.csv.CSVRecord> collectCsvRecordIterable​(File file)
                                                                                   throws IOException
        collect an iterable given that each country specific file is in CSV format
        Parameters:
        file - presumed compatible with country specific CSV format
        Returns:
        CSVRecord iterable
        Throws:
        IOException - thrown if error
      • collectCsvRecordIterable

        public static Iterable<org.apache.commons.csv.CSVRecord> collectCsvRecordIterable​(Reader readerToUse)
                                                                                   throws IOException
        Collect an iterable for the given reader
        Parameters:
        readerToUse - the reader to use
        Returns:
        CSVRecord iterable
        Throws:
        IOException - thrown if error