Source:
<code>static Metadata decode(ByteBuf body, boolean withPkIndices, ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { EnumSet<Flag> flags = Flag.deserialize(body.readInt()); int columnCount = body.readInt(); MD5Digest resultMetadataId = null; if (flags.contains(Flag.METADATA_CHANGED)) { <START> assert protocolVersion == ProtocolVersion.V5 : "MetadataChanged flag is supported starting from v5"; <END> assert !flags.contains(Flag.NO_METADATA) : "MetadataChanged and NoMetadata are mutually exclusive flags"; resultMetadataId = MD5Digest.wrap(CBUtil.readBytes(body)); } int[] pkIndices = null; int pkCount; if (withPkIndices && (pkCount = body.readInt()) > 0) { pkIndices = new int[pkCount]; for (int i = 0; i < pkCount; i++) pkIndices[i] = (int) body.readShort(); } ByteBuffer state = null; if (flags.contains(Flag.HAS_MORE_PAGES)) state = CBUtil.readValue(body); if (flags.contains(Flag.NO_METADATA)) return new Metadata(resultMetadataId, columnCount, null, state, pkIndices); boolean globalTablesSpec = flags.contains(Flag.GLOBAL_TABLES_SPEC); String globalKsName = null; String globalCfName = null; if (globalTablesSpec) { globalKsName = CBUtil.readString(body); globalCfName = CBUtil.readString(body); } ColumnDefinitions.Definition[] defs = new ColumnDefinitions.Definition[columnCount]; for (int i = 0; i < columnCount; i++) { String ksName = globalTablesSpec ? globalKsName : CBUtil.readString(body); String cfName = globalTablesSpec ? globalCfName : CBUtil.readString(body); String name = CBUtil.readString(body); DataType type = DataType.decode(body, protocolVersion, codecRegistry); defs[i] = new ColumnDefinitions.Definition(ksName, cfName, name, type); } return new Metadata(resultMetadataId, columnCount, new ColumnDefinitions(defs, codecRegistry), state, pkIndices); }</code><technical_language>Nit: MetadataChanged -> METADATA_CHANGED</technical_language>

Target:
static Metadata decode(ByteBuf body, boolean withPkIndices, ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { EnumSet<Flag> flags = Flag.deserialize(body.readInt()); int columnCount = body.readInt(); ByteBuffer state = null; if (flags.contains(Flag.HAS_MORE_PAGES)) state = CBUtil.readValue(body); MD5Digest resultMetadataId = null; if (flags.contains(Flag.METADATA_CHANGED)) { assert ProtocolFeature.PREPARED_METADATA_CHANGES.isSupportedBy(protocolVersion) : "METADATA_CHANGED flag is not supported in protocol version " + protocolVersion; assert !flags.contains(Flag.NO_METADATA) : "METADATA_CHANGED and NO_METADATA are mutually exclusive flags"; resultMetadataId = MD5Digest.wrap(CBUtil.readBytes(body)); } int[] pkIndices = null; int pkCount; if (withPkIndices && (pkCount = body.readInt()) > 0) { pkIndices = new int[pkCount]; for (int i = 0; i < pkCount; i++) pkIndices[i] = (int) body.readShort(); } if (flags.contains(Flag.NO_METADATA)) return new Metadata(resultMetadataId, columnCount, null, state, pkIndices); boolean globalTablesSpec = flags.contains(Flag.GLOBAL_TABLES_SPEC); String globalKsName = null; String globalCfName = null; if (globalTablesSpec) { globalKsName = CBUtil.readString(body); globalCfName = CBUtil.readString(body); } ColumnDefinitions.Definition[] defs = new ColumnDefinitions.Definition[columnCount]; for (int i = 0; i < columnCount; i++) { String ksName = globalTablesSpec ? globalKsName : CBUtil.readString(body); String cfName = globalTablesSpec ? globalCfName : CBUtil.readString(body); String name = CBUtil.readString(body); DataType type = DataType.decode(body, protocolVersion, codecRegistry); defs[i] = new ColumnDefinitions.Definition(ksName, cfName, name, type); } return new Metadata(resultMetadataId, columnCount, new ColumnDefinitions(defs, codecRegistry), state, pkIndices); }