package moe.odango.index.entity import io.requery.* import moe.odango.index.utils.EntityHelper import moe.odango.index.utils.helper import java.util.* @Entity interface AniDBInfo : Persistable { @get:Key val id: UUID @get:OneToOne @get:ForeignKey val anime: Anime var type: ReleaseType var restricted: Boolean var episodes: Int? var description: String var image: String? var startYear: Int? var startMonth: Int? var startDay: Int? var endYear: Int? var endMonth: Int? var endDay: Int? enum class ReleaseType { Movie, MusicVideo, OVA, Other, TVSeries, TVSpecial, Web, Unknown; companion object { fun fromAniDBString(value: String): ReleaseType = when (value.toLowerCase()) { "movie" -> Movie "music video" -> MusicVideo "ova" -> OVA "other" -> Other "tv series" -> TVSeries "tv special" -> TVSpecial "web" -> Web else -> Unknown } } } companion object : EntityHelper by helper(::AniDBInfoEntity, { setId(UUID.randomUUID()) }) }