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

io.github.springwolf.bindings.sqs.scanners.messages.SqsMessageBindingProcessor Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.bindings.sqs.scanners.messages;

import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSMessageBinding;
import io.github.springwolf.bindings.sqs.annotations.SqsAsyncOperationBinding;
import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor;
import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.util.StringValueResolver;

import java.lang.reflect.AnnotatedElement;
import java.util.Arrays;
import java.util.Optional;

public class SqsMessageBindingProcessor implements MessageBindingProcessor, EmbeddedValueResolverAware {
    private StringValueResolver resolver;

    @Override
    public void setEmbeddedValueResolver(StringValueResolver resolver) {
        this.resolver = resolver;
    }

    @Override
    public Optional process(AnnotatedElement annotatedElement) {
        return Arrays.stream(annotatedElement.getAnnotations())
                .filter(SqsAsyncOperationBinding.class::isInstance)
                .map(SqsAsyncOperationBinding.class::cast)
                .findAny()
                .map(this::mapToMessageBinding);
    }

    private ProcessedMessageBinding mapToMessageBinding(SqsAsyncOperationBinding bindingAnnotation) {
        SQSMessageBinding sqsMessageBinding = new SQSMessageBinding();

        return new ProcessedMessageBinding("sqs", sqsMessageBinding);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy