override fun read()

in model/src/main/kotlin/com/android/gradle/replicator/model/internal/DefaultModuleInfo.kt [84:135]


    override fun read(input: JsonReader): DefaultModuleInfo {
        var path: String? = null
        var plugins: List<PluginType> = listOf()
        var javaSources: SourceFilesInfo? = null
        var kotlinSources: SourceFilesInfo? = null
        var androidResources: AndroidResourcesInfo? = null
        var javaResources: FilesWithSizeMetadataInfo? = null
        var assets: FilesWithSizeMetadataInfo? = null
        var dependencies: List<DependenciesInfo> = listOf()
        var androidInfo: AndroidInfo? = null

        val sourceFilesAdapter = SourceFilesAdapter()
        val filesWithSizeMetadataAdapter = FilesWithSizeMetadataAdapter()
        val resourcesAdapter = AndroidResourcesAdapter()

        input.readObjectProperties {
            when (it) {
                "path" -> path = nextString()
                "plugins" -> plugins = input.readArrayToList {
                    val id = nextString()
                    PluginType.values().firstOrNull { it.id == id || it.oldId == id }
                            ?: throw RuntimeException("Unable to find PluginType for value '$id'")
                }

                "javaSources" -> javaSources = sourceFilesAdapter.read(input)
                "kotlinSources" -> kotlinSources = sourceFilesAdapter.read(input)
                "androidResources" -> androidResources = resourcesAdapter.read(input)
                "javaResources" -> javaResources = filesWithSizeMetadataAdapter.read(input)
                "assets" -> assets = filesWithSizeMetadataAdapter.read(input)
                "dependencies" -> {
                    val dependenciesAdapter = DependenciesAdapter()
                    dependencies = input.readArrayToList {
                        dependenciesAdapter.read(this)
                    }
                }
                "android" -> androidInfo = AndroidAdapter().read(input)
                else -> skipValue()
            }
        }

        return DefaultModuleInfo(
            path = path ?: throw RuntimeException("Missing module path"),
            plugins = plugins,
            javaSources = javaSources,
            kotlinSources = kotlinSources,
            androidResources = androidResources,
            javaResources = javaResources,
            assets = assets,
            dependencies = dependencies,
            android = androidInfo
        )
    }