Created
April 11, 2018 03:13
-
-
Save dphans/5fc563471362d77e3b310f777208fc65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dinophan.authapp.bases | |
import com.google.gson.Gson | |
import com.google.gson.annotations.Expose | |
import com.google.gson.annotations.SerializedName | |
import java.io.Serializable | |
@Suppress("MemberVisibilityCanBePrivate", "RedundantVisibilityModifier") | |
abstract class BaseModel: Serializable { | |
@SerializedName("_id") | |
var _id: Long = -1 | |
@SerializedName("_created_at") | |
var _created_at: Long = System.currentTimeMillis() | |
@SerializedName("_updated_at") | |
var _updated_at: Long = System.currentTimeMillis() | |
@Expose | |
var errorMessage: String? = null | |
open fun validates(): Boolean = true | |
fun toJson(): String = try { | |
Gson().toJson(this@BaseModel) | |
} catch (jsonParsingException: Exception) { | |
[email protected] = jsonParsingException.localizedMessage | |
"{}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment