Made all methods and properties overridable
This commit is contained in:
parent
0c55c0e0b0
commit
2fd11b2e56
|
@ -6,10 +6,10 @@ import java.io.File
|
||||||
|
|
||||||
|
|
||||||
open class BankListCreator @JvmOverloads constructor(
|
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) {
|
deutscheKreditwirtschaftXlsxFile: File) {
|
||||||
|
|
||||||
val banks = parser.parse(deutscheKreditwirtschaftXlsxFile)
|
val banks = parser.parse(deutscheKreditwirtschaftXlsxFile)
|
||||||
|
|
|
@ -23,7 +23,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun parse(bankListFile: File): List<DetailedBankInfo> {
|
open fun parse(bankListFile: File): List<DetailedBankInfo> {
|
||||||
val xlsxPkg = SpreadsheetMLPackage.load(bankListFile)
|
val xlsxPkg = SpreadsheetMLPackage.load(bankListFile)
|
||||||
|
|
||||||
val workbookPart = xlsxPkg.getWorkbookPart()
|
val workbookPart = xlsxPkg.getWorkbookPart()
|
||||||
|
@ -49,7 +49,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
return mapBankCodeAndServerAddressesList(bankCodesList, serverAddressesList)
|
return mapBankCodeAndServerAddressesList(bankCodesList, serverAddressesList)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mapBankCodeAndServerAddressesList(banks: List<BankCodeListEntry>,
|
protected open fun mapBankCodeAndServerAddressesList(banks: List<BankCodeListEntry>,
|
||||||
serverAddresses: List<ServerAddressesListEntry>): List<DetailedBankInfo> {
|
serverAddresses: List<ServerAddressesListEntry>): List<DetailedBankInfo> {
|
||||||
|
|
||||||
val serverAddressesByBankCode = mutableMapOf<String, MutableList<ServerAddressesListEntry>>()
|
val serverAddressesByBankCode = mutableMapOf<String, MutableList<ServerAddressesListEntry>>()
|
||||||
|
@ -65,7 +65,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
return banks.map { mapToBankInfo(it, serverAddressesByBankCode as Map<String, List<ServerAddressesListEntry>>) }
|
return banks.map { mapToBankInfo(it, serverAddressesByBankCode as Map<String, List<ServerAddressesListEntry>>) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mapToBankInfo(bank: BankCodeListEntry,
|
protected open fun mapToBankInfo(bank: BankCodeListEntry,
|
||||||
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>): DetailedBankInfo {
|
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>): DetailedBankInfo {
|
||||||
|
|
||||||
val serverAddress = findServerAddress(bank, serverAddressesByBankCode)
|
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<String, List<ServerAddressesListEntry>>
|
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>
|
||||||
): ServerAddressesListEntry? {
|
): 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"))
|
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<ServerAddressesListEntry> {
|
List<ServerAddressesListEntry> {
|
||||||
|
|
||||||
val entries = mutableListOf<ServerAddressesListEntry>()
|
val entries = mutableListOf<ServerAddressesListEntry>()
|
||||||
|
@ -128,7 +128,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
return entries
|
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,
|
bankCodeColumnIndex: Int, bicColumnIndex: Int, cityColumnIndex: Int,
|
||||||
pinTanAddressColumnIndex: Int, pinTanVersionColumnIndex: Int):
|
pinTanAddressColumnIndex: Int, pinTanVersionColumnIndex: Int):
|
||||||
ServerAddressesListEntry? {
|
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"))
|
return hasHeaders(workSheetData, formatter, listOf("Bankleitzahl", "Merkmal"))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseBankCodeList(workSheetData: SheetData, formatter: DataFormatter): List<BankCodeListEntry> {
|
protected open fun parseBankCodeList(workSheetData: SheetData, formatter: DataFormatter): List<BankCodeListEntry> {
|
||||||
val entries = mutableListOf<BankCodeListEntry>()
|
val entries = mutableListOf<BankCodeListEntry>()
|
||||||
|
|
||||||
val headerRow = workSheetData.row[0]
|
val headerRow = workSheetData.row[0]
|
||||||
|
@ -197,7 +197,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
return entries
|
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,
|
bankCodeColumnIndex: Int, bicColumnIndex: Int, postalCodeColumnIndex: Int,
|
||||||
cityColumnIndex: Int, checksumMethodColumnIndex: Int,
|
cityColumnIndex: Int, checksumMethodColumnIndex: Int,
|
||||||
bankCodeDeletedColumnIndex: Int, newBankCodeColumnIndex: Int): BankCodeListEntry? {
|
bankCodeDeletedColumnIndex: Int, newBankCodeColumnIndex: Int): BankCodeListEntry? {
|
||||||
|
@ -233,7 +233,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
/**
|
/**
|
||||||
* Deleted banks may not have a BIC. This method fixes this
|
* Deleted banks may not have a BIC. This method fixes this
|
||||||
*/
|
*/
|
||||||
private fun updateDeletedBanks(banks: MutableList<BankCodeListEntry>) {
|
protected open fun updateDeletedBanks(banks: MutableList<BankCodeListEntry>) {
|
||||||
val banksByCode = banks.associateBy { it.bankCode }
|
val banksByCode = banks.associateBy { it.bankCode }
|
||||||
|
|
||||||
val deletedBanks = banks.filter { it.isBankCodeDeleted }
|
val deletedBanks = banks.filter { it.isBankCodeDeleted }
|
||||||
|
@ -246,7 +246,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun hasHeaders(workSheetData: SheetData, formatter: DataFormatter, headerNames: List<String>): Boolean {
|
protected open fun hasHeaders(workSheetData: SheetData, formatter: DataFormatter, headerNames: List<String>): Boolean {
|
||||||
if (workSheetData.row.isNotEmpty()) {
|
if (workSheetData.row.isNotEmpty()) {
|
||||||
val headerRow = workSheetData.row[0]
|
val headerRow = workSheetData.row[0]
|
||||||
|
|
||||||
|
@ -258,18 +258,18 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
return false
|
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)
|
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
|
if (cell.f != null) { // cell with formular
|
||||||
return cell.v
|
return cell.v
|
||||||
}
|
}
|
||||||
return formatter.formatCellValue(cell)
|
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) }
|
return row.c.joinToString("\t|", "|\t", "\t|") { getCellText(it, formatter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@ package net.dankito.banking.banklistcreator.parser.model
|
||||||
|
|
||||||
|
|
||||||
open class BankCodeListEntry(
|
open class BankCodeListEntry(
|
||||||
val bankName: String,
|
open val bankName: String,
|
||||||
val bankCode: String,
|
open val bankCode: String,
|
||||||
var bic: String, // TODO: make val again
|
open var bic: String, // TODO: make val again
|
||||||
val postalCode: String,
|
open val postalCode: String,
|
||||||
val city: String,
|
open val city: String,
|
||||||
val checksumMethod: String,
|
open val checksumMethod: String,
|
||||||
val oldBankCode: String?
|
open val oldBankCode: String?
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val isBankCodeDeleted: Boolean
|
open val isBankCodeDeleted: Boolean
|
||||||
get() = oldBankCode != null
|
get() = oldBankCode != null
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@ package net.dankito.banking.banklistcreator.parser.model
|
||||||
|
|
||||||
|
|
||||||
open class ServerAddressesListEntry(
|
open class ServerAddressesListEntry(
|
||||||
val bankName: String,
|
open val bankName: String,
|
||||||
val bankCode: String,
|
open val bankCode: String,
|
||||||
val bic: String,
|
open val bic: String,
|
||||||
val city: String,
|
open val city: String,
|
||||||
val pinTanAddress: String?,
|
open val pinTanAddress: String?,
|
||||||
val pinTanVersion: String?
|
open val pinTanVersion: String?
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
|
Loading…
Reference in New Issue