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

com.avito.android.critical_path.internal.CriticalPathReport.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

There is a newer version: 2023.22
Show newest version
package com.avito.android.critical_path.internal

import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import java.io.File

internal class CriticalPathReport(
    private val report: File
) {

    private val gson = GsonBuilder()
        .create()

    fun write(records: List) {
        ensureReportExists()
        report.writeText(gson.toJson(records))
    }

    fun read(): List {
        val type = object : TypeToken>() {}.type
        return gson.fromJson(report.bufferedReader(), type)
    }

    private fun ensureReportExists() {
        if (!report.exists()) {
            report.parentFile.mkdirs()
            report.createNewFile()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy