From 2fd11b2e5664d67458fbf6678d2394bc0b5fe4a5 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 16 Sep 2020 22:39:02 +0200 Subject: [PATCH] Made all methods and properties overridable --- .../banklistcreator/BankListCreator.kt | 4 +-- .../DeutscheKreditwirtschaftBankListParser.kt | 30 +++++++++---------- .../parser/model/BankCodeListEntry.kt | 16 +++++----- .../parser/model/ServerAddressesListEntry.kt | 12 ++++---- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/BankListCreator.kt b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/BankListCreator.kt index 684b1c70..6112e3a4 100644 --- a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/BankListCreator.kt +++ b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/BankListCreator.kt @@ -6,10 +6,10 @@ import java.io.File open class BankListCreator @JvmOverloads constructor( - protected val parser: DeutscheKreditwirtschaftBankListParser = DeutscheKreditwirtschaftBankListParser() + protected open val parser: DeutscheKreditwirtschaftBankListParser = DeutscheKreditwirtschaftBankListParser() ) { - fun createBankListFromDeutscheKreditwirtschaftXlsxFile(bankFileOutputFile: File, + open fun createBankListFromDeutscheKreditwirtschaftXlsxFile(bankFileOutputFile: File, deutscheKreditwirtschaftXlsxFile: File) { val banks = parser.parse(deutscheKreditwirtschaftXlsxFile) diff --git a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/DeutscheKreditwirtschaftBankListParser.kt b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/DeutscheKreditwirtschaftBankListParser.kt index c620d3b7..71c3ade3 100644 --- a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/DeutscheKreditwirtschaftBankListParser.kt +++ b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/DeutscheKreditwirtschaftBankListParser.kt @@ -23,7 +23,7 @@ open class DeutscheKreditwirtschaftBankListParser { } - fun parse(bankListFile: File): List { + open fun parse(bankListFile: File): List { val xlsxPkg = SpreadsheetMLPackage.load(bankListFile) val workbookPart = xlsxPkg.getWorkbookPart() @@ -49,7 +49,7 @@ open class DeutscheKreditwirtschaftBankListParser { return mapBankCodeAndServerAddressesList(bankCodesList, serverAddressesList) } - private fun mapBankCodeAndServerAddressesList(banks: List, + protected open fun mapBankCodeAndServerAddressesList(banks: List, serverAddresses: List): List { val serverAddressesByBankCode = mutableMapOf>() @@ -65,7 +65,7 @@ open class DeutscheKreditwirtschaftBankListParser { return banks.map { mapToBankInfo(it, serverAddressesByBankCode as Map>) } } - private fun mapToBankInfo(bank: BankCodeListEntry, + protected open fun mapToBankInfo(bank: BankCodeListEntry, serverAddressesByBankCode: Map>): DetailedBankInfo { val serverAddress = findServerAddress(bank, serverAddressesByBankCode) @@ -83,7 +83,7 @@ open class DeutscheKreditwirtschaftBankListParser { ) } - private fun findServerAddress(bankCode: BankCodeListEntry, + protected open fun findServerAddress(bankCode: BankCodeListEntry, serverAddressesByBankCode: Map> ): ServerAddressesListEntry? { @@ -99,11 +99,11 @@ open class DeutscheKreditwirtschaftBankListParser { } - private fun isListWithFinTsServerAddresses(workSheetData: SheetData, formatter: DataFormatter): Boolean { + protected open fun isListWithFinTsServerAddresses(workSheetData: SheetData, formatter: DataFormatter): Boolean { return hasHeaders(workSheetData, formatter, listOf("BLZ", "PIN/TAN-Zugang URL")) } - private fun parseListWithFinTsServerAddresses(workSheetData: SheetData, formatter: DataFormatter): + protected open fun parseListWithFinTsServerAddresses(workSheetData: SheetData, formatter: DataFormatter): List { val entries = mutableListOf() @@ -128,7 +128,7 @@ open class DeutscheKreditwirtschaftBankListParser { return entries } - private fun parseToServerAddressesListEntry(row: Row, formatter: DataFormatter, bankNameColumnIndex: Int, + protected open fun parseToServerAddressesListEntry(row: Row, formatter: DataFormatter, bankNameColumnIndex: Int, bankCodeColumnIndex: Int, bicColumnIndex: Int, cityColumnIndex: Int, pinTanAddressColumnIndex: Int, pinTanVersionColumnIndex: Int): ServerAddressesListEntry? { @@ -155,11 +155,11 @@ open class DeutscheKreditwirtschaftBankListParser { } - private fun isBankCodeList(workSheetData: SheetData, formatter: DataFormatter): Boolean { + protected open fun isBankCodeList(workSheetData: SheetData, formatter: DataFormatter): Boolean { return hasHeaders(workSheetData, formatter, listOf("Bankleitzahl", "Merkmal")) } - private fun parseBankCodeList(workSheetData: SheetData, formatter: DataFormatter): List { + protected open fun parseBankCodeList(workSheetData: SheetData, formatter: DataFormatter): List { val entries = mutableListOf() val headerRow = workSheetData.row[0] @@ -197,7 +197,7 @@ open class DeutscheKreditwirtschaftBankListParser { return entries } - private fun parseToBankCodeListEntry(row: Row, formatter: DataFormatter, bankNameColumnIndex: Int, + protected open fun parseToBankCodeListEntry(row: Row, formatter: DataFormatter, bankNameColumnIndex: Int, bankCodeColumnIndex: Int, bicColumnIndex: Int, postalCodeColumnIndex: Int, cityColumnIndex: Int, checksumMethodColumnIndex: Int, bankCodeDeletedColumnIndex: Int, newBankCodeColumnIndex: Int): BankCodeListEntry? { @@ -233,7 +233,7 @@ open class DeutscheKreditwirtschaftBankListParser { /** * Deleted banks may not have a BIC. This method fixes this */ - private fun updateDeletedBanks(banks: MutableList) { + protected open fun updateDeletedBanks(banks: MutableList) { val banksByCode = banks.associateBy { it.bankCode } val deletedBanks = banks.filter { it.isBankCodeDeleted } @@ -246,7 +246,7 @@ open class DeutscheKreditwirtschaftBankListParser { } - private fun hasHeaders(workSheetData: SheetData, formatter: DataFormatter, headerNames: List): Boolean { + protected open fun hasHeaders(workSheetData: SheetData, formatter: DataFormatter, headerNames: List): Boolean { if (workSheetData.row.isNotEmpty()) { val headerRow = workSheetData.row[0] @@ -258,18 +258,18 @@ open class DeutscheKreditwirtschaftBankListParser { return false } - private fun getCellText(row: Row, columnIndex: Int, formatter: DataFormatter): String { + protected open fun getCellText(row: Row, columnIndex: Int, formatter: DataFormatter): String { return getCellText(row.c[columnIndex], formatter) } - private fun getCellText(cell: Cell, formatter: DataFormatter): String { + protected open fun getCellText(cell: Cell, formatter: DataFormatter): String { if (cell.f != null) { // cell with formular return cell.v } return formatter.formatCellValue(cell) } - private fun getRowAsString(row: Row, formatter: DataFormatter): String { + protected open fun getRowAsString(row: Row, formatter: DataFormatter): String { return row.c.joinToString("\t|", "|\t", "\t|") { getCellText(it, formatter) } } diff --git a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/BankCodeListEntry.kt b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/BankCodeListEntry.kt index 11b39616..e3df9af0 100644 --- a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/BankCodeListEntry.kt +++ b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/BankCodeListEntry.kt @@ -2,16 +2,16 @@ package net.dankito.banking.banklistcreator.parser.model open class BankCodeListEntry( - val bankName: String, - val bankCode: String, - var bic: String, // TODO: make val again - val postalCode: String, - val city: String, - val checksumMethod: String, - val oldBankCode: String? + open val bankName: String, + open val bankCode: String, + open var bic: String, // TODO: make val again + open val postalCode: String, + open val city: String, + open val checksumMethod: String, + open val oldBankCode: String? ) { - val isBankCodeDeleted: Boolean + open val isBankCodeDeleted: Boolean get() = oldBankCode != null diff --git a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/ServerAddressesListEntry.kt b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/ServerAddressesListEntry.kt index 5c7c47fa..701ba448 100644 --- a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/ServerAddressesListEntry.kt +++ b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/parser/model/ServerAddressesListEntry.kt @@ -2,12 +2,12 @@ package net.dankito.banking.banklistcreator.parser.model open class ServerAddressesListEntry( - val bankName: String, - val bankCode: String, - val bic: String, - val city: String, - val pinTanAddress: String?, - val pinTanVersion: String? + open val bankName: String, + open val bankCode: String, + open val bic: String, + open val city: String, + open val pinTanAddress: String?, + open val pinTanVersion: String? ) { override fun toString(): String {