From b427ff532b6d28acc46e0b9daeba0520c79a3e3b Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Sun, 26 Jul 2020 20:32:02 +0200 Subject: [PATCH] small cleanup --- .../modpacktools/util/ModpackJsonHandler.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/ModpackJsonHandler.kt b/src/main/kotlin/ley/anvil/modpacktools/util/ModpackJsonHandler.kt index 477e7c4..37f5683 100644 --- a/src/main/kotlin/ley/anvil/modpacktools/util/ModpackJsonHandler.kt +++ b/src/main/kotlin/ley/anvil/modpacktools/util/ModpackJsonHandler.kt @@ -6,16 +6,14 @@ import java.io.File import java.io.FileReader class ModpackJsonHandler(val modpackJsonFile: File) { - var asWrapper: ASWrapper? = null - private set - get() = field ?: run { - if(modpackJsonFile.exists()) { - val reader = FileReader(modpackJsonFile) - field = ASWrapper(AddonscriptJSON.read(reader, AddonscriptJSON::class.java)) - reader.close() - } - field - } + val asWrapper: ASWrapper? by lazy { + if(modpackJsonFile.exists()) { + val reader = FileReader(modpackJsonFile) + val ret = ASWrapper(AddonscriptJSON.read(reader, AddonscriptJSON::class.java)) + reader.close() + ret + } else null + } val json: AddonscriptJSON? get() = asWrapper?.json