Skip to content

Commit 0d07fa8

Browse files
committed
spotless
1 parent c58ecaf commit 0d07fa8

File tree

14 files changed

+108
-57
lines changed

14 files changed

+108
-57
lines changed

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/AggregateException.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package com.trendyol.kediatr
55
*
66
* @since 1.0.9
77
*/
8-
class AggregateException(val exceptions: Collection<Throwable>) : RuntimeException() {
8+
class AggregateException(
9+
val exceptions: Collection<Throwable>
10+
) : RuntimeException() {
911
constructor(exceptions: Array<Throwable>) : this(exceptions.toList())
1012
}

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/CommandProvider.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ internal class CommandProvider<H : CommandHandler<*>>(
99
private val dependencyProvider: DependencyProvider,
1010
private val type: Class<H>
1111
) {
12-
fun get(): H {
13-
return dependencyProvider.getSingleInstanceOf(type)
14-
}
12+
fun get(): H = dependencyProvider.getSingleInstanceOf(type)
1513
}
1614

1715
/**
@@ -24,7 +22,5 @@ internal class CommandWithResultProvider<H : CommandWithResultHandler<*, *>>(
2422
private val dependencyProvider: DependencyProvider,
2523
private val type: Class<H>
2624
) {
27-
fun get(): H {
28-
return dependencyProvider.getSingleInstanceOf(type)
29-
}
25+
fun get(): H = dependencyProvider.getSingleInstanceOf(type)
3026
}

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/Container.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.trendyol.kediatr
22

33
@Suppress("UNCHECKED_CAST")
4-
internal class Container(dependencyProvider: DependencyProvider) : Registrar() {
4+
internal class Container(
5+
dependencyProvider: DependencyProvider
6+
) : Registrar() {
57
val commandMap = HashMap<Class<*>, CommandProvider<CommandHandler<Command>>>()
68
val queryMap = HashMap<Class<*>, QueryProvider<QueryHandler<*, *>>>()
79
val notificationMap = HashMap<Class<*>, MutableList<NotificationProvider<NotificationHandler<*>>>>()
@@ -27,7 +29,8 @@ internal class Container(dependencyProvider: DependencyProvider) : Registrar() {
2729
}
2830

2931
registerFor<NotificationHandler<Notification>, Notification>(dependencyProvider) { key, value ->
30-
notificationMap.getOrPut(key) { mutableListOf() }
32+
notificationMap
33+
.getOrPut(key) { mutableListOf() }
3134
.add(NotificationProvider(dependencyProvider, value as Class<NotificationHandler<*>>))
3235
}
3336

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
package com.trendyol.kediatr
22

3-
class HandlerNotFoundException(message: String) : Exception(message)
3+
class HandlerNotFoundException(
4+
message: String
5+
) : Exception(message)

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/MediatorBuilder.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ class MediatorBuilder(
2222
return this
2323
}
2424

25-
fun build(registry: Registry = RegistryImpl(dependencyProvider)): Mediator {
26-
return MediatorImpl(registry, defaultPublishStrategy)
27-
}
25+
fun build(registry: Registry = RegistryImpl(dependencyProvider)): Mediator = MediatorImpl(registry, defaultPublishStrategy)
2826
}

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/NotificationProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ internal class NotificationProvider<H : NotificationHandler<*>>(
44
private val dependencyProvider: DependencyProvider,
55
private val type: Class<H>
66
) {
7-
fun get(): H {
8-
return dependencyProvider.getSingleInstanceOf(type)
9-
}
7+
fun get(): H = dependencyProvider.getSingleInstanceOf(type)
108
}

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/PipelineProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ internal class PipelineProvider<H : PipelineBehavior>(
99
private val dependencyProvider: DependencyProvider,
1010
private val type: Class<H>
1111
) {
12-
fun get(): H {
13-
return dependencyProvider.getSingleInstanceOf(type)
14-
}
12+
fun get(): H = dependencyProvider.getSingleInstanceOf(type)
1513
}

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/QueryProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ internal class QueryProvider<H : QueryHandler<*, *>>(
99
private val dependencyProvider: DependencyProvider,
1010
private val type: Class<H>
1111
) {
12-
fun get(): H {
13-
return dependencyProvider.getSingleInstanceOf(type)
14-
}
12+
fun get(): H = dependencyProvider.getSingleInstanceOf(type)
1513
}

projects/kediatr-core/src/main/kotlin/com/trendyol/kediatr/RegistryImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class RegistryImpl(
2626
override fun <TNotification : Notification> resolveNotificationHandlers(
2727
classOfNotification: Class<TNotification>
2828
): Collection<NotificationHandler<TNotification>> =
29-
registry.notificationMap.filter { (k, _) -> k.isAssignableFrom(classOfNotification) }
29+
registry.notificationMap
30+
.filter { (k, _) -> k.isAssignableFrom(classOfNotification) }
3031
.flatMap { (_, v) -> v.map { it.get() as NotificationHandler<TNotification> } }
3132

3233
override fun <TQuery : Query<TResult>, TResult> resolveQueryHandler(classOfQuery: Class<TQuery>): QueryHandler<TQuery, TResult> {

projects/kediatr-core/src/testFixtures/kotlin/com/trendyol/kediatr/testing/models.kt

Lines changed: 82 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ abstract class EnrichedWithMetadata {
3737
}
3838
}
3939

40-
class Result(val value: Int = 0)
40+
class Result(
41+
val value: Int = 0
42+
)
4143

4244
class TestNonExistCommand : Command
4345

@@ -49,7 +51,9 @@ class NonExistQuery : Query<String>
4951
* Notifications
5052
*/
5153

52-
class TestNotification : Notification, EnrichedWithMetadata()
54+
class TestNotification :
55+
EnrichedWithMetadata(),
56+
Notification
5357

5458
class TestNotificationHandler(
5559
private val mediator: MediatorAccessor
@@ -60,7 +64,9 @@ class TestNotificationHandler(
6064
}
6165
}
6266

63-
open class Ping : Notification, EnrichedWithMetadata()
67+
open class Ping :
68+
EnrichedWithMetadata(),
69+
Notification
6470

6571
class ExtendedPing : Ping()
6672

@@ -76,7 +82,9 @@ class AnotherPingHandler : NotificationHandler<Ping> {
7682
}
7783
}
7884

79-
class NotificationForMultipleHandlers : Notification, EnrichedWithMetadata()
85+
class NotificationForMultipleHandlers :
86+
EnrichedWithMetadata(),
87+
Notification
8088

8189
class Handler1ForNotificationOfMultipleHandlers : NotificationHandler<NotificationForMultipleHandlers> {
8290
override suspend fun handle(notification: NotificationForMultipleHandlers) {
@@ -90,7 +98,9 @@ class Handler2ForNotificationOfMultipleHandlers : NotificationHandler<Notificati
9098
}
9199
}
92100

93-
class PingForInherited : Notification, EnrichedWithMetadata()
101+
class PingForInherited :
102+
EnrichedWithMetadata(),
103+
Notification
94104

95105
abstract class NotificationHandlerBase<TNotification : Notification> : NotificationHandler<TNotification>
96106

@@ -100,7 +110,10 @@ class InheritedNotificationHandler : NotificationHandlerBase<PingForInherited>()
100110
}
101111
}
102112

103-
class ParameterizedNotification<T>(val param: T) : Notification, EnrichedWithMetadata()
113+
class ParameterizedNotification<T>(
114+
val param: T
115+
) : EnrichedWithMetadata(),
116+
Notification
104117

105118
class ParameterizedNotificationHandler<A> : NotificationHandler<ParameterizedNotification<A>> {
106119
override suspend fun handle(notification: ParameterizedNotification<A>) {
@@ -109,7 +122,10 @@ class ParameterizedNotificationHandler<A> : NotificationHandler<ParameterizedNot
109122
}
110123
}
111124

112-
class ParameterizedNotificationForInheritance<T>(val param: T) : Notification, EnrichedWithMetadata()
125+
class ParameterizedNotificationForInheritance<T>(
126+
val param: T
127+
) : EnrichedWithMetadata(),
128+
Notification
113129

114130
class ParameterizedNotificationHandlerForInheritance<T> : NotificationHandlerBase<ParameterizedNotificationForInheritance<T>>() {
115131
override suspend fun handle(notification: ParameterizedNotificationForInheritance<T>) {
@@ -122,15 +138,19 @@ class ParameterizedNotificationHandlerForInheritance<T> : NotificationHandlerBas
122138
* Commands
123139
*/
124140

125-
class TestCommandForWithoutInjection : Command, EnrichedWithMetadata()
141+
class TestCommandForWithoutInjection :
142+
EnrichedWithMetadata(),
143+
Command
126144

127145
class TestCommandHandlerWithoutInjection : CommandHandler<TestCommandForWithoutInjection> {
128146
override suspend fun handle(command: TestCommandForWithoutInjection) {
129147
command.incrementInvocationCount()
130148
}
131149
}
132150

133-
class TestCommand : Command, EnrichedWithMetadata()
151+
class TestCommand :
152+
EnrichedWithMetadata(),
153+
Command
134154

135155
class TestCommandHandler(
136156
private val mediator: MediatorAccessor
@@ -141,9 +161,14 @@ class TestCommandHandler(
141161
}
142162
}
143163

144-
data class TestCommandWithResult(val invoked: Int = 0) : CommandWithResult<Result>, EnrichedWithMetadata()
164+
data class TestCommandWithResult(
165+
val invoked: Int = 0
166+
) : EnrichedWithMetadata(),
167+
CommandWithResult<Result>
145168

146-
class TestCommandWithResultCommandHandler(val mediator: MediatorAccessor) : CommandWithResultHandler<TestCommandWithResult, Result> {
169+
class TestCommandWithResultCommandHandler(
170+
val mediator: MediatorAccessor
171+
) : CommandWithResultHandler<TestCommandWithResult, Result> {
147172
override suspend fun handle(
148173
command: TestCommandWithResult
149174
): Result = Result(command.invoked + 1).also {
@@ -153,8 +178,8 @@ class TestCommandWithResultCommandHandler(val mediator: MediatorAccessor) : Comm
153178
}
154179

155180
class CommandThatPassesThroughPipelineBehaviours :
156-
Command,
157181
EnrichedWithMetadata(),
182+
Command,
158183
CanPassLoggingPipelineBehaviour,
159184
CanPassExceptionPipelineBehaviour,
160185
CanPassInheritedPipelineBehaviour
@@ -169,8 +194,8 @@ class TestPipelineCommandHandler(
169194
}
170195

171196
class CommandForWithoutInjectionThatPassesThroughPipelineBehaviours :
172-
Command,
173197
EnrichedWithMetadata(),
198+
Command,
174199
CanPassLoggingPipelineBehaviour,
175200
CanPassExceptionPipelineBehaviour,
176201
CanPassInheritedPipelineBehaviour
@@ -181,7 +206,9 @@ class TestPipelineCommandHandlerWithoutInjection : CommandHandler<CommandForWith
181206
}
182207
}
183208

184-
class CommandThatFailsWhilePassingThroughPipelineBehaviours : Command, EnrichedWithMetadata()
209+
class CommandThatFailsWhilePassingThroughPipelineBehaviours :
210+
EnrichedWithMetadata(),
211+
Command
185212

186213
class TestPipelineCommandHandlerThatFails : CommandHandler<CommandThatFailsWhilePassingThroughPipelineBehaviours> {
187214
override suspend fun handle(command: CommandThatFailsWhilePassingThroughPipelineBehaviours) {
@@ -190,7 +217,9 @@ class TestPipelineCommandHandlerThatFails : CommandHandler<CommandThatFailsWhile
190217
}
191218
}
192219

193-
class TestCommandThatFailsWithException : Command, EnrichedWithMetadata()
220+
class TestCommandThatFailsWithException :
221+
EnrichedWithMetadata(),
222+
Command
194223

195224
class TestBrokenCommandHandler(
196225
private val mediator: MediatorAccessor
@@ -202,7 +231,9 @@ class TestBrokenCommandHandler(
202231
}
203232
}
204233

205-
class TestCommandForInheritance : Command, EnrichedWithMetadata()
234+
class TestCommandForInheritance :
235+
EnrichedWithMetadata(),
236+
Command
206237

207238
abstract class MyCommandHandlerBaseForSpecificCommand : CommandHandler<TestCommandForInheritance>
208239

@@ -212,7 +243,9 @@ class TestInheritedCommandHandlerForSpecificCommand : MyCommandHandlerBaseForSpe
212243
}
213244
}
214245

215-
class TestCommandForTypeLimitedInheritance : Command, EnrichedWithMetadata()
246+
class TestCommandForTypeLimitedInheritance :
247+
EnrichedWithMetadata(),
248+
Command
216249

217250
abstract class TestBaseCommandHandlerForTypeLimitedInheritance<TCommand : Command> : CommandHandler<TCommand>
218251

@@ -223,7 +256,10 @@ class TestCommandHandlerForTypeLimitedInheritance :
223256
}
224257
}
225258

226-
class ParameterizedCommand<T>(val param: T) : Command, EnrichedWithMetadata()
259+
class ParameterizedCommand<T>(
260+
val param: T
261+
) : EnrichedWithMetadata(),
262+
Command
227263

228264
class ParameterizedCommandHandler<T> : CommandHandler<ParameterizedCommand<T>> {
229265
override suspend fun handle(command: ParameterizedCommand<T>) {
@@ -232,7 +268,10 @@ class ParameterizedCommandHandler<T> : CommandHandler<ParameterizedCommand<T>> {
232268
}
233269
}
234270

235-
class ParameterizedCommandForInheritedCommandHandler<T>(val param: T) : Command, EnrichedWithMetadata()
271+
class ParameterizedCommandForInheritedCommandHandler<T>(
272+
val param: T
273+
) : EnrichedWithMetadata(),
274+
Command
236275

237276
abstract class ParameterizedCommandHandlerBaseForInheritedCommandHandler<A> :
238277
CommandHandler<ParameterizedCommandForInheritedCommandHandler<A>>
@@ -247,7 +286,8 @@ class ParameterizedCommandHandlerForInheritance<A> : ParameterizedCommandHandler
247286
class ParameterizedCommandWithResult<TParam, TReturn>(
248287
val param: TParam,
249288
val retFn: suspend (TParam) -> TReturn
250-
) : CommandWithResult<TReturn>, EnrichedWithMetadata()
289+
) : EnrichedWithMetadata(),
290+
CommandWithResult<TReturn>
251291

252292
class ParameterizedCommandWithResultHandler<TParam, TReturn> :
253293
CommandWithResultHandler<ParameterizedCommandWithResult<TParam, TReturn>, TReturn> {
@@ -258,7 +298,10 @@ class ParameterizedCommandWithResultHandler<TParam, TReturn> :
258298
}
259299
}
260300

261-
data class ParameterizedCommandWithResultForInheritance<TParam>(val param: TParam) : CommandWithResult<String>, EnrichedWithMetadata()
301+
data class ParameterizedCommandWithResultForInheritance<TParam>(
302+
val param: TParam
303+
) : EnrichedWithMetadata(),
304+
CommandWithResult<String>
262305

263306
abstract class ParameterizedCommandWithResultHandlerBase<TParam : CommandWithResult<String>> : CommandWithResultHandler<TParam, String>
264307

@@ -275,7 +318,10 @@ class ParameterizedCommandWithResultHandlerOfInheritedHandler<TParam> :
275318
* Queries
276319
*/
277320

278-
class TestQuery(val id: Int) : Query<String>, EnrichedWithMetadata()
321+
class TestQuery(
322+
val id: Int
323+
) : EnrichedWithMetadata(),
324+
Query<String>
279325

280326
class TestQueryHandler(
281327
private val mediator: MediatorAccessor
@@ -290,7 +336,8 @@ class TestQueryHandler(
290336
class ParameterizedQuery<TParam, TResponse>(
291337
val param: TParam,
292338
val retFn: suspend (TParam) -> TResponse
293-
) : Query<TResponse>, EnrichedWithMetadata()
339+
) : EnrichedWithMetadata(),
340+
Query<TResponse>
294341

295342
class ParameterizedQueryHandler<TParam, TResponse> : QueryHandler<ParameterizedQuery<TParam, TResponse>, TResponse> {
296343
override suspend fun handle(query: ParameterizedQuery<TParam, TResponse>): TResponse {
@@ -360,11 +407,20 @@ class InheritedPipelineBehaviour : MyBasePipelineBehaviour() {
360407

361408
interface OrderedPipelineUseCase
362409

363-
class CommandThatPassesThroughOrderedPipelineBehaviours : Command, EnrichedWithMetadata(), OrderedPipelineUseCase
410+
class CommandThatPassesThroughOrderedPipelineBehaviours :
411+
EnrichedWithMetadata(),
412+
Command,
413+
OrderedPipelineUseCase
364414

365-
class QueryThatPassesThroughOrderedPipelineBehaviours : Query<String>, EnrichedWithMetadata(), OrderedPipelineUseCase
415+
class QueryThatPassesThroughOrderedPipelineBehaviours :
416+
EnrichedWithMetadata(),
417+
Query<String>,
418+
OrderedPipelineUseCase
366419

367-
class NotificationThatPassesThroughOrderedPipelineBehaviours : Notification, EnrichedWithMetadata(), OrderedPipelineUseCase
420+
class NotificationThatPassesThroughOrderedPipelineBehaviours :
421+
EnrichedWithMetadata(),
422+
Notification,
423+
OrderedPipelineUseCase
368424

369425
class CommandHandlerThatPassesThroughOrderedPipelineBehaviours : CommandHandler<CommandThatPassesThroughOrderedPipelineBehaviours> {
370426
override suspend fun handle(command: CommandThatPassesThroughOrderedPipelineBehaviours) {

0 commit comments

Comments
 (0)