From 0a2f095f46d444d0d1f94f0e59d8966313abf67f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 4 Sep 2018 10:56:43 +0800 Subject: [PATCH] add DI and rename (again) use cases --- .../PsychomatrixBase/di/EntitiesDI.kt | 4 ++++ .../PsychomatrixBase/di/PresentationLayerDI.kt | 9 +++++++++ .../insanusmokrassar/PsychomatrixBase/di/UIDI.kt | 7 +++++++ .../PsychomatrixBase/di/UseCasesDI.kt | 7 +++++++ .../di/realisations/EntitiesDIImpl.kt | 7 +++++++ .../di/realisations/PresentationLayerDIImpl.kt | 15 +++++++++++++++ .../PsychomatrixBase/di/realisations/UIDIImpl.kt | 7 +++++++ .../di/realisations/UseCasesDIImpl.kt | 13 +++++++++++++ ...ixByDate.kt => CalculatePsychomatrixByDate.kt} | 2 +- ...t => CalculatePsychomatrixByDateInteractor.kt} | 4 ++-- .../DatePickerPresenterImpl.kt | 6 +++--- 11 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/EntitiesDI.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/PresentationLayerDI.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UIDI.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UseCasesDI.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/EntitiesDIImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/PresentationLayerDIImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UIDIImpl.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UseCasesDIImpl.kt rename src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/{UserCalculatePsychomatrixByDate.kt => CalculatePsychomatrixByDate.kt} (93%) rename src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/{UserCalculatePsychomatrixByDateInteractor.kt => CalculatePsychomatrixByDateInteractor.kt} (91%) diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/EntitiesDI.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/EntitiesDI.kt new file mode 100644 index 0000000..39b2d01 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/EntitiesDI.kt @@ -0,0 +1,4 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di + +interface EntitiesDI { +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/PresentationLayerDI.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/PresentationLayerDI.kt new file mode 100644 index 0000000..e456218 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/PresentationLayerDI.kt @@ -0,0 +1,9 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di + +import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter + +interface PresentationLayerDI : UseCasesDI { + + val datePickerPresenter: DatePickerPresenter + +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UIDI.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UIDI.kt new file mode 100644 index 0000000..1b89c96 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UIDI.kt @@ -0,0 +1,7 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di + +import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter + +interface UIDI : PresentationLayerDI { + +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UseCasesDI.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UseCasesDI.kt new file mode 100644 index 0000000..169b94a --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/UseCasesDI.kt @@ -0,0 +1,7 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di + +import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate + +interface UseCasesDI : EntitiesDI { + val calculatePsychomatrixByDate: CalculatePsychomatrixByDate +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/EntitiesDIImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/EntitiesDIImpl.kt new file mode 100644 index 0000000..97fac88 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/EntitiesDIImpl.kt @@ -0,0 +1,7 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di.realisations + +import com.github.insanusmokrassar.PsychomatrixBase.di.EntitiesDI + +open class EntitiesDIImpl : EntitiesDI { + +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/PresentationLayerDIImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/PresentationLayerDIImpl.kt new file mode 100644 index 0000000..3e87595 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/PresentationLayerDIImpl.kt @@ -0,0 +1,15 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di.realisations + +import com.github.insanusmokrassar.PsychomatrixBase.di.PresentationLayerDI +import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter +import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations.DatePickerPresenterImpl + +open class PresentationLayerDIImpl : PresentationLayerDI, UseCasesDIImpl() { + + override val datePickerPresenter: DatePickerPresenter by lazy { + DatePickerPresenterImpl( + calculatePsychomatrixByDate + ) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UIDIImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UIDIImpl.kt new file mode 100644 index 0000000..97ed62c --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UIDIImpl.kt @@ -0,0 +1,7 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di.realisations + +import com.github.insanusmokrassar.PsychomatrixBase.di.UIDI + +class UIDIImpl : UIDI, PresentationLayerDIImpl() { + +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UseCasesDIImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UseCasesDIImpl.kt new file mode 100644 index 0000000..7915a18 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/di/realisations/UseCasesDIImpl.kt @@ -0,0 +1,13 @@ +package com.github.insanusmokrassar.PsychomatrixBase.di.realisations + +import com.github.insanusmokrassar.PsychomatrixBase.di.UseCasesDI +import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate +import com.github.insanusmokrassar.PsychomatrixBase.domain.interactors.CalculatePsychomatrixByDateInteractor + +open class UseCasesDIImpl : UseCasesDI, EntitiesDIImpl() { + + override val calculatePsychomatrixByDate: CalculatePsychomatrixByDate by lazy { + CalculatePsychomatrixByDateInteractor() + } + +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/UserCalculatePsychomatrixByDate.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/CalculatePsychomatrixByDate.kt similarity index 93% rename from src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/UserCalculatePsychomatrixByDate.kt rename to src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/CalculatePsychomatrixByDate.kt index 7fa6dc3..588bcc5 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/UserCalculatePsychomatrixByDate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/UseCases/CalculatePsychomatrixByDate.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.experimental.channels.ReceiveChannel import org.joda.time.DateTime import java.util.* -interface UserCalculatePsychomatrixByDate { +interface CalculatePsychomatrixByDate { suspend fun calculate(date: Long): Deferred suspend fun calculate(date: DateTime): Deferred suspend fun calculate(date: Date): Deferred diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/UserCalculatePsychomatrixByDateInteractor.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/CalculatePsychomatrixByDateInteractor.kt similarity index 91% rename from src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/UserCalculatePsychomatrixByDateInteractor.kt rename to src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/CalculatePsychomatrixByDateInteractor.kt index 1829198..8efca8d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/UserCalculatePsychomatrixByDateInteractor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/domain/interactors/CalculatePsychomatrixByDateInteractor.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.PsychomatrixBase.domain.interactors -import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCalculatePsychomatrixByDate +import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.Psychomatrix import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM import kotlinx.coroutines.experimental.Deferred @@ -10,7 +10,7 @@ import kotlinx.coroutines.experimental.channels.ReceiveChannel import org.joda.time.DateTime import java.util.* -class UserCalculatePsychomatrixByDateInteractor : UserCalculatePsychomatrixByDate { +class CalculatePsychomatrixByDateInteractor : CalculatePsychomatrixByDate { private val psychomatrixCreatedBroadcast = BroadcastChannel(SUBSCRIPTIONS_MEDIUM) override suspend fun calculate(date: Long): Deferred { diff --git a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/DatePickerPresenterImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/DatePickerPresenterImpl.kt index 2197e51..a3d3543 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/DatePickerPresenterImpl.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/PsychomatrixBase/presentation/presenters/DefaultRealisations/DatePickerPresenterImpl.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DefaultRealisations -import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.UserCalculatePsychomatrixByDate +import com.github.insanusmokrassar.PsychomatrixBase.domain.UseCases.CalculatePsychomatrixByDate import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.Psychomatrix import com.github.insanusmokrassar.PsychomatrixBase.presentation.presenters.DatePickerPresenter import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM @@ -10,7 +10,7 @@ import kotlinx.coroutines.experimental.launch import org.joda.time.DateTime class DatePickerPresenterImpl( - private val userCalculatePsychomatrixByDate: UserCalculatePsychomatrixByDate + private val CalculatePsychomatrixByDate: CalculatePsychomatrixByDate ) : DatePickerPresenter { private val psychomatrixCreateBroadcastChannel = BroadcastChannel(SUBSCRIPTIONS_MEDIUM) @@ -24,7 +24,7 @@ class DatePickerPresenterImpl( override fun userPickDate(date: DateTime) { launch { - userCalculatePsychomatrixByDate.calculate(date).await().also { + CalculatePsychomatrixByDate.calculate(date).await().also { psychomatrixCreateBroadcastChannel.send(it) } }