Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
fix: fix the reality of operation usage.
Browse files Browse the repository at this point in the history
Signed-off-by: Ibrahim AlTamimi <ibm.iloom@gmail.com>
  • Loading branch information
ibm-iloom committed Feb 28, 2021
1 parent 3221edd commit 3a72ce8
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 32 deletions.
2 changes: 1 addition & 1 deletion ktx-radix-adapter/ktx-radix-adapter-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-adapter</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ interface Operator<RQ, RS> {
fun RQ.operate(response: RS)
}

infix fun <RQ, RS> Operation<RQ, RS>.operationBuilder(
infix fun <RQ, RS> Operation<RQ, RS>.runOperation(request: RQ) = request.operate()

fun <RQ, RS> operationBuilder(
builder: OperationBuilder<RQ, RS>.() -> Unit,
): Operation<RQ, RS> =
OperationBuilder(this)
OperationBuilder<RQ, RS>()
.apply {
builder()
}

class OperationBuilder<RQ, RS>(
private val mainOperation: Operation<RQ, RS>,
) : Operation<RQ, RS> {
class OperationBuilder<RQ, RS> : Operation<RQ, RS> {
private val roles: MutableList<OperationRole<RQ, Unit>> = mutableListOf()
private val afterOperators: MutableList<Operator<RQ, RS>> = mutableListOf()
private lateinit var mainOperation: Operation<RQ, RS>

private fun RQ.before() =
roles.forEach { it.run { operateRole() } }
Expand All @@ -46,6 +47,10 @@ class OperationBuilder<RQ, RS>(
this.afterOperators.add(operator)
}

infix fun mainOperation(operation: Operation<RQ, RS>) {
this.mainOperation = operation
}

infix fun after(operator: RQ.(RS) -> Unit) {
this.afterOperators.add(object : Operator<RQ, RS> {
override fun RQ.operate(response: RS) {
Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-development/ktx-radix-development-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-development/ktx-radix-development-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -17,5 +17,10 @@
<artifactId>ktx-radix-development-usecase-validation</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>ktx-radix-development-operation</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.quee.ktx.radix.develop.usecase

import io.quee.ktx.radix.develop.operation.Operation
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.model.UseCaseResponse

/**
* Created By [*Ibrahim Al-Tamimi *](https://www.linkedin.com/in/iloom/)
* Created At 28, **Sun February, 2021**
* Project *ktx-radix* [Quee.IO]
*/
fun <RQ : UseCaseRequest, RS : UseCaseResponse> FunctionalUseCase<RQ, RS>.toOperation(): Operation<RQ, RS> =
UseCaseOperation {
process()
}

fun <RQ : UseCaseRequest> CommandUseCase<RQ>.toOperation(): Operation<RQ, Unit> =
UseCaseOperation {
execute()
}

private class UseCaseOperation<RQ, RS>(
private val function: RQ.() -> RS,
) : Operation<RQ, RS> {
override fun RQ.operate() = function()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-development/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-port/ktx-radix-port-logger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-port</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-port/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-starter/ktx-radix-starter-logger-webflux/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-starter</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-starter/ktx-radix-starter-logger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-starter</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-starter/ktx-radix-starter-tracker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-starter</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-tool/ktx-radix-tool-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-tool</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-tool/ktx-radix-tool-json-dsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-tool</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-tool/ktx-radix-tool-test-dsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-tool</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-tool/ktx-radix-tool-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-tool</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-tool/ktx-radix-tool-tracker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-tool</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.quee.ktx.radix</groupId>
<artifactId>ktx-radix</artifactId>
<packaging>pom</packaging>
<version>v1.2.2-RELEASE</version>
<version>v1.2.3-RELEASE</version>
<modules>
<module>ktx-radix-port</module>
<module>ktx-radix-adapter</module>
Expand Down

0 comments on commit 3a72ce8

Please sign in to comment.