private static ClientMessage convertFromOutsideMessage()

in protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java [222:287]


    private static <E> ClientMessage<E> convertFromOutsideMessage(Message<E> source) throws ClientException {
        Header header = new Header();
        header.setDurable(source.durable());
        header.setPriority(source.priority());
        header.setTimeToLive(source.timeToLive());
        header.setFirstAcquirer(source.firstAcquirer());
        header.setDeliveryCount(source.deliveryCount());

        Properties properties = new Properties();
        properties.setMessageId(source.messageId());
        properties.setUserId(source.userId() != null ? new Binary(source.userId()) : null);
        properties.setTo(source.to());
        properties.setSubject(source.subject());
        properties.setReplyTo(source.replyTo());
        properties.setCorrelationId(source.correlationId());
        properties.setContentType(source.contentType());
        properties.setContentEncoding(source.contentEncoding());
        properties.setAbsoluteExpiryTime(source.absoluteExpiryTime());
        properties.setCreationTime(source.creationTime());
        properties.setGroupId(source.groupId());
        properties.setGroupSequence(source.groupSequence());
        properties.setReplyToGroupId(source.replyToGroupId());

        final MessageAnnotations messageAnnotations;
        if (source.hasAnnotations()) {
            messageAnnotations = new MessageAnnotations(new LinkedHashMap<>());

            source.forEachAnnotation((key, value) -> {
                messageAnnotations.getValue().put(Symbol.valueOf(key), value);
            });
        } else {
            messageAnnotations = null;
        }

        final ApplicationProperties applicationProperties;
        if (source.hasProperties()) {
            applicationProperties = new ApplicationProperties(new LinkedHashMap<>());

            source.forEachProperty((key, value) -> {
                applicationProperties.getValue().put(key, value);
            });
        } else {
            applicationProperties = null;
        }

        final Footer footer;
        if (source.hasFooters()) {
            footer = new Footer(new LinkedHashMap<>());

            source.forEachFooter((key, value) -> {
                footer.getValue().put(Symbol.valueOf(key), value);
            });
        } else {
            footer = null;
        }

        ClientMessage<E> message = new ClientMessage<>(createSectionFromValue(source.body()));

        message.header(header);
        message.properties(properties);
        message.annotations(messageAnnotations);
        message.applicationProperties(applicationProperties);
        message.footer(footer);

        return message;
    }