diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt index 174c16a2..02e52161 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -14,7 +14,6 @@ import net.dankito.banking.ui.model.tan.EnterTanGeneratorAtcResult import net.dankito.banking.ui.model.tan.EnterTanResult import net.dankito.banking.ui.model.tan.TanChallenge import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium -import net.dankito.banking.util.IBankIconFinder import net.dankito.banking.bankfinder.IBankFinder import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.search.IRemitteeSearcher @@ -23,16 +22,11 @@ import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPd import net.dankito.banking.ui.model.moneytransfer.ExtractTransferMoneyDataFromPdfResultType import net.dankito.banking.ui.model.parameters.GetTransactionsParameter import net.dankito.banking.ui.model.settings.AppSettings -import net.dankito.banking.util.CoroutinesAsyncRunner -import net.dankito.banking.util.IAsyncRunner +import net.dankito.banking.util.* import net.dankito.text.extraction.ITextExtractorRegistry import net.dankito.text.extraction.info.invoice.IInvoiceDataExtractor import net.dankito.text.extraction.info.invoice.InvoiceDataExtractor import net.dankito.text.extraction.model.ErrorType -import net.dankito.utils.extensions.containsExactly -import net.dankito.utils.extensions.ofMaxLength -import net.dankito.utils.serialization.ISerializer -import net.dankito.utils.serialization.JacksonJsonSerializer import org.slf4j.LoggerFactory import java.io.File import java.io.FileOutputStream diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/Extensions.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/Extensions.kt new file mode 100644 index 00000000..1010a826 --- /dev/null +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/Extensions.kt @@ -0,0 +1,29 @@ +package net.dankito.banking.util + + +fun String.ofMaxLength(maxLength: Int): String { + if(this.length > maxLength && maxLength > 0) { + return this.substring(0, maxLength) + } + + return this +} + + +fun Collection.containsExactly(vararg items: T): Boolean { + return containsExactly(items.toList()) +} + +fun Collection.containsExactly(otherCollection: Collection): Boolean { + if (this.size != otherCollection.size) { + return false + } + + for (otherItem in otherCollection) { + if (this.contains(otherItem) == false) { + return false + } + } + + return true +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ISerializer.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ISerializer.kt new file mode 100644 index 00000000..197b187f --- /dev/null +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/ISerializer.kt @@ -0,0 +1,12 @@ +package net.dankito.banking.util + +import java.io.File + + +interface ISerializer { + + fun serializeObject(obj: Any, outputFile: File) + + fun deserializeObject(serializedObjectFile: File, objectClass: Class, vararg genericParameterTypes: Class<*>): T? + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/JacksonJsonSerializer.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/JacksonJsonSerializer.kt new file mode 100644 index 00000000..0b9a01ef --- /dev/null +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/JacksonJsonSerializer.kt @@ -0,0 +1,20 @@ +package net.dankito.banking.util + +import net.dankito.utils.serialization.JacksonJsonSerializer +import java.io.File + + +open class JacksonJsonSerializer( + protected val serializer: net.dankito.utils.serialization.ISerializer = JacksonJsonSerializer() +) : ISerializer { + + override fun serializeObject(obj: Any, outputFile: File) { + return serializer.serializeObject(obj, outputFile) + } + + override fun deserializeObject(serializedObjectFile: File, objectClass: Class, + vararg genericParameterTypes: Class<*>): T? { + return serializer.deserializeObject(serializedObjectFile, objectClass, *genericParameterTypes) + } + +} \ No newline at end of file diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpSerializer.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpSerializer.kt new file mode 100644 index 00000000..e0ecd084 --- /dev/null +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/util/NoOpSerializer.kt @@ -0,0 +1,16 @@ +package net.dankito.banking.util + +import java.io.File + + +open class NoOpSerializer : ISerializer { + + override fun serializeObject(obj: Any, outputFile: File) { + + } + + override fun deserializeObject(serializedObjectFile: File, objectClass: Class, vararg genericParameterTypes: Class<*>): T? { + return null + } + +} \ No newline at end of file