All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.iris_events.asyncapi.parsers.RoutingKeyParser Maven / Gradle / Ivy

There is a newer version: 6.1.8
Show newest version
package org.iris_events.asyncapi.parsers;

import java.util.Objects;

import org.iris_events.annotations.Message;
import org.iris_events.asyncapi.runtime.util.JandexUtil;
import org.jboss.jandex.AnnotationInstance;

public class RoutingKeyParser {
    private static final String MESSAGE_ROUTING_KEY_PARAM = "routingKey";

    public static String getFromAnnotationClass(final Message messageAnnotation) {
        final var routingKey = messageAnnotation.routingKey();
        if (Objects.nonNull(routingKey) && !routingKey.isBlank()) {
            return routingKey;
        }
        return ExchangeParser.getFromAnnotationClass(messageAnnotation);
    }

    public static String getFromAnnotationInstance(final AnnotationInstance messageAnnotation) {
        return JandexUtil.optionalStringValue(messageAnnotation, MESSAGE_ROUTING_KEY_PARAM)
                .orElse(ExchangeParser.getFromAnnotationInstance(messageAnnotation));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy