private Target readTarget()

in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/messaging/TargetTypeDecoder.java [78:123]


    private Target readTarget(ProtonBuffer buffer, DecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
        final Target target = new Target();

        @SuppressWarnings("unused")
        final int size = listDecoder.readSize(buffer, state);
        final int count = listDecoder.readCount(buffer, 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(buffer, state));
                    break;
                case 1:
                    final long durability = state.getDecoder().readUnsignedInteger(buffer, state, 0);
                    target.setDurable(TerminusDurability.valueOf(durability));
                    break;
                case 2:
                    final Symbol expiryPolicy = state.getDecoder().readSymbol(buffer, state);
                    target.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
                    break;
                case 3:
                    final UnsignedInteger timeout = state.getDecoder().readUnsignedInteger(buffer, state);
                    target.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
                    break;
                case 4:
                    target.setDynamic(state.getDecoder().readBoolean(buffer, state, false));
                    break;
                case 5:
                    target.setDynamicNodeProperties(state.getDecoder().readMap(buffer, state));
                    break;
                case 6:
                    target.setCapabilities(state.getDecoder().readMultiple(buffer, state, Symbol.class));
                    break;
            }
        }

        return target;
    }