From f95e5e291e99f09d3b7e813059e7f7b80c3c12ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 21 Feb 2020 13:32:18 +0100 Subject: [PATCH] =?utf8?q?=E2=99=BB=EF=B8=8F=20Replace=20=E2=80=9Cnormal?= =?utf8?q?=E2=80=9D=20methods=20with=20extension=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/sone/fcp/AbstractSoneCommand.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/fcp/AbstractSoneCommand.kt b/src/main/kotlin/net/pterodactylus/sone/fcp/AbstractSoneCommand.kt index 08e0593..f884e34 100644 --- a/src/main/kotlin/net/pterodactylus/sone/fcp/AbstractSoneCommand.kt +++ b/src/main/kotlin/net/pterodactylus/sone/fcp/AbstractSoneCommand.kt @@ -44,12 +44,12 @@ abstract class AbstractSoneCommand val requiresWriteAccess: Boolean = false) : AbstractCommand() { @Throws(FcpException::class) - protected fun getSone(simpleFieldSet: SimpleFieldSet, parameterName: String, localOnly: Boolean): Sone = - getSone(simpleFieldSet, parameterName, localOnly, true).get() + protected fun SimpleFieldSet.getSone(parameterName: String, localOnly: Boolean): Sone = + getSone(parameterName, localOnly, true).get() @Throws(FcpException::class) - protected fun getSone(simpleFieldSet: SimpleFieldSet, parameterName: String, localOnly: Boolean, mandatory: Boolean): Optional { - val soneId = simpleFieldSet.get(parameterName) + protected fun SimpleFieldSet.getSone(parameterName: String, localOnly: Boolean, mandatory: Boolean): Optional { + val soneId = get(parameterName) .throwOnNullIf(mandatory) { FcpException("Could not load Sone ID from “$parameterName”.") } ?: return Optional.absent() val sone = core.getSone(soneId) @@ -60,9 +60,9 @@ abstract class AbstractSoneCommand } @Throws(FcpException::class) - protected fun getPost(simpleFieldSet: SimpleFieldSet, parameterName: String): Post { + protected fun SimpleFieldSet.getPost(parameterName: String): Post { try { - val postId = simpleFieldSet.getString(parameterName) + val postId = getString(parameterName) return core.getPost(postId) ?: throw FcpException("Could not load post from “$postId”.") } catch (fspe1: FSParseException) { @@ -71,9 +71,9 @@ abstract class AbstractSoneCommand } @Throws(FcpException::class) - protected fun getReply(simpleFieldSet: SimpleFieldSet, parameterName: String): PostReply { + protected fun SimpleFieldSet.getReply(parameterName: String): PostReply { try { - val replyId = simpleFieldSet.getString(parameterName) + val replyId = getString(parameterName) return core.getPostReply(replyId) ?: throw FcpException("Could not load reply from “$replyId”.") } catch (fspe1: FSParseException) { -- 2.7.4