public static ApiTextMessageEx fromBytes(byte[] src) throws IOException { BserValues values = new BserValues(BserParser.deserialize(new DataInput(src, 0, src.length))); int key = values.getInt(1); byte[] content = values.getBytes(2); switch (key) { case 1: return Bser.parse(new ApiTextExMarkdown(), content); case 2: return Bser.parse(new ApiTextModernMessage(), content); case 3: return Bser.parse(new ApiTextCommand(), content); default: return new ApiTextMessageExUnsupported(key, content); } }