in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/messaging/TargetTypeDecoder.java [144:189]
private Target readTarget(InputStream stream, StreamDecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
final Target target = new Target();
@SuppressWarnings("unused")
final int size = listDecoder.readSize(stream, state);
final int count = listDecoder.readCount(stream, state);
if (count < MIN_TARGET_LIST_ENTRIES) {
throw new DecodeException("Not enough entries in Target list encoding: " + count);
}
if (count > MAX_TARGET_LIST_ENTRIES) {
throw new DecodeException("To many entries in Target list encoding: " + count);
}
for (int index = 0; index < count; ++index) {
switch (index) {
case 0:
target.setAddress(state.getDecoder().readString(stream, state));
break;
case 1:
final long durability = state.getDecoder().readUnsignedInteger(stream, state, 0);
target.setDurable(TerminusDurability.valueOf(durability));
break;
case 2:
final Symbol expiryPolicy = state.getDecoder().readSymbol(stream, state);
target.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
break;
case 3:
final UnsignedInteger timeout = state.getDecoder().readUnsignedInteger(stream, state);
target.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
break;
case 4:
target.setDynamic(state.getDecoder().readBoolean(stream, state, false));
break;
case 5:
target.setDynamicNodeProperties(state.getDecoder().readMap(stream, state));
break;
case 6:
target.setCapabilities(state.getDecoder().readMultiple(stream, state, Symbol.class));
break;
}
}
return target;
}