001/*
002 * Copyright 2002-2019 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.messaging.handler.invocation.reactive;
018
019import reactor.core.publisher.Mono;
020
021import org.springframework.core.MethodParameter;
022import org.springframework.lang.Nullable;
023import org.springframework.messaging.Message;
024
025/**
026 * An extension of {@link HandlerMethodArgumentResolver} for implementations
027 * that are synchronous in nature and do not block to resolve values.
028 *
029 * @author Rossen Stoyanchev
030 * @since 5.2
031 */
032public interface SyncHandlerMethodArgumentResolver extends HandlerMethodArgumentResolver {
033
034        /**
035         * {@inheritDoc}
036         * <p>By default this simply delegates to {@link #resolveArgumentValue} for
037         * synchronous resolution.
038         */
039        @Override
040        default Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) {
041                return Mono.justOrEmpty(resolveArgumentValue(parameter, message));
042        }
043
044        /**
045         * Resolve the value for the method parameter synchronously.
046         * @param parameter the method parameter
047         * @param message the currently processed message
048         * @return the resolved value, if any
049         */
050        @Nullable
051        Object resolveArgumentValue(MethodParameter parameter, Message<?> message);
052
053}