All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.pocketbyte.locolaser.mobile.parser.IosClassResourcesConfigParser.kt Maven / Gradle / Ivy

Go to download

Implementation of platform for LocoLaser tool to work with Android and iOS platforms.

There is a newer version: 2.5.0
Show newest version
package ru.pocketbyte.locolaser.mobile.parser

import org.json.simple.JSONObject
import ru.pocketbyte.locolaser.config.parser.ConfigParser
import ru.pocketbyte.locolaser.config.resources.BaseResourcesConfig
import ru.pocketbyte.locolaser.exception.InvalidConfigException
import ru.pocketbyte.locolaser.mobile.IosBaseClassResourcesConfig
import ru.pocketbyte.locolaser.mobile.IosObjectiveCResourcesConfig
import ru.pocketbyte.locolaser.mobile.IosSwiftResourcesConfig
import ru.pocketbyte.locolaser.utils.json.JsonParseUtils

class IosClassResourcesConfigParser : BaseMobileResourcesConfigParser() {

    companion object {
        const val TABLE_NAME = "table_name"
    }

    @Throws(InvalidConfigException::class)
    override fun parseJSONObject(platformJSON: JSONObject, throwIfWrongType: Boolean): BaseResourcesConfig? {
        val config = super.parseJSONObject(platformJSON, throwIfWrongType) as IosBaseClassResourcesConfig?

        if (config != null) {

            config.tableName = JsonParseUtils.getString(
                    platformJSON, TABLE_NAME, ConfigParser.PLATFORM, false)
        }

        return config
    }

    @Throws(InvalidConfigException::class)
    override fun platformByType(type: String?, throwIfWrongType: Boolean): BaseResourcesConfig? {
        if (IosSwiftResourcesConfig.TYPE == type)
            return IosSwiftResourcesConfig()
        if (IosObjectiveCResourcesConfig.TYPE == type)
            return IosObjectiveCResourcesConfig()

        if (throwIfWrongType)
            throw InvalidConfigException("Unknown platform: $type")

        return null
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy