aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfkrzywka <filip.krzywka@nokia.com>2018-06-05 14:51:36 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-01 11:20:58 +0200
commit763b680bea3f5c14e70453845d7670f7ae691e87 (patch)
treea3302c7b8417fe312321ada3f5bafd1c17936d31
parent23438166832778b36f3aac7b3cc0b81ab6e8da1e (diff)
Duplicate code removal
Change-Id: Iee19bce0ba18746d0570337c5317ccdd63552d56 Signed-off-by: fkrzywka <filip.krzywka@nokia.com> Issue-ID: DCAEGEN2-601
-rw-r--r--hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt11
1 files changed, 2 insertions, 9 deletions
diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt
index b0f877f0..9cade1cc 100644
--- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt
+++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt
@@ -59,13 +59,7 @@ internal class VesHvCollector(
return valid
}
- private fun findRoute(msg: VesMessage): Mono<RoutedMessage> {
- val routedMessage = router.findDestination(msg)
- return if (routedMessage == null)
- Mono.empty()
- else
- Mono.just(routedMessage)
- }
+ private fun findRoute(msg: VesMessage): Mono<RoutedMessage> = omitWhenNull(msg, router::findDestination)
private fun releaseMemory(msg: VesMessage) {
msg.rawMessage.release()
@@ -73,8 +67,7 @@ internal class VesHvCollector(
- private fun <T>omitWhenNull(input: ByteBuf, mapper: (ByteBuf) -> T?): Mono<T> =
- Mono.justOrEmpty(mapper(input))
+ private fun <T, V>omitWhenNull(input: T, mapper: (T) -> V?): Mono<V> = Mono.justOrEmpty(mapper(input))
private fun <T>releaseWhenNull(input: ByteBuf, mapper: (ByteBuf) -> T?): Mono<T> {
val result = mapper(input)