package com.zaojiao.app.core.json.adapter

import com.squareup.moshi.FromJson
import com.squareup.moshi.JsonQualifier
import com.squareup.moshi.ToJson

@Retention(value = AnnotationRetention.RUNTIME)
@JsonQualifier
annotation class StateInt

class StateIntAdapter {
    @ToJson
    fun toJson(@StateInt state: Boolean): Int {
        return if (state) 1 else 0
    }

    @FromJson
    @StateInt
    fun fromJson(state: Int): Boolean {
        return state == 1
    }
}