From b385551aaa0750cb0041858037cd83dcbf9006b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 11 Dec 2019 22:03:56 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Use=20Runnable=20instead=20of=20a?= =?utf8?q?=20Kotlin=20arrow=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt | 7 ++++++- .../net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt index e090133..9d0522d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPinger.kt @@ -20,14 +20,19 @@ package net.pterodactylus.sone.freenet.wot import com.google.common.eventbus.* import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.freenet.plugin.* +import net.pterodactylus.sone.utils.* import java.util.concurrent.atomic.* +import javax.inject.* /** * [Runnable] that is scheduled via an [Executor][java.util.concurrent.Executor], * checks whether the web of trust plugin can be communicated with, sends * events if its status changes and reschedules itself. */ -class WebOfTrustPinger(private val eventBus: EventBus, private val webOfTrustReacher: () -> Unit, private val reschedule: () -> Unit) : Runnable { +class WebOfTrustPinger @Inject constructor( + private val eventBus: EventBus, + @Named("webOfTrustReacher") private val webOfTrustReacher: Runnable, + @Named("webOfTrustReschedule") private val reschedule: Runnable) : Runnable { private val lastState = AtomicBoolean(false) diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt index 894b9ef..9743449 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustPingerTest.kt @@ -33,9 +33,9 @@ class WebOfTrustPingerTest { private val eventBus = EventBus() private val webOfTrustReachable = AtomicBoolean() - private val webOfTrustReacher: () -> Unit = { webOfTrustReachable.get().onFalse { throw PluginException() } } + private val webOfTrustReacher = Runnable { webOfTrustReachable.get().onFalse { throw PluginException() } } private val rescheduled = AtomicBoolean() - private val reschedule: () -> Unit = { rescheduled.set(true) } + private val reschedule = Runnable { rescheduled.set(true) } private val pinger = WebOfTrustPinger(eventBus, webOfTrustReacher, reschedule) @Test -- 2.7.4