ref: v3.7.0
app/src/main/java/xyz/apiote/bimba/czwek/api/responses/Line.kt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
// SPDX-FileCopyrightText: Adam Evyčędo // // SPDX-License-Identifier: GPL-3.0-or-later package xyz.apiote.bimba.czwek.api.responses import xyz.apiote.bimba.czwek.api.LineV1 import xyz.apiote.bimba.czwek.api.LineV2 import xyz.apiote.bimba.czwek.api.LineV3 import xyz.apiote.fruchtfleisch.Reader import java.io.InputStream interface LineResponse { companion object { fun unmarshal(stream: InputStream): LineResponse { val reader = Reader(stream) return when (val v = reader.readUInt().toULong()) { // 0UL -> LineResponseDev.unmarshal(stream) 1UL -> LineResponseV1.unmarshal(stream) 2UL -> LineResponseV2.unmarshal(stream) 3UL -> LineResponseV3.unmarshal(stream) else -> throw UnknownResponseVersion("Line", v) } } } } data class LineResponseV3( val line: LineV3 ) : LineResponse { companion object { fun unmarshal(stream: InputStream): LineResponseV3 { return LineResponseV3(LineV3.unmarshal(stream)) } } } data class LineResponseV2( val line: LineV2 ) : LineResponse { companion object { fun unmarshal(stream: InputStream): LineResponseV2 { return LineResponseV2(LineV2.unmarshal(stream)) } } } data class LineResponseV1( val line: LineV1 ) : LineResponse { companion object { fun unmarshal(stream: InputStream): LineResponseV1 { return LineResponseV1(LineV1.unmarshal(stream)) } } } |