001/*
002 * Copyright 2002-2015 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;
018
019import org.springframework.core.MethodParameter;
020import org.springframework.lang.Nullable;
021import org.springframework.messaging.Message;
022
023/**
024 * Strategy interface for resolving method parameters into argument values
025 * in the context of a given {@link Message}.
026 *
027 * @author Rossen Stoyanchev
028 * @since 4.0
029 */
030public interface HandlerMethodArgumentResolver {
031
032        /**
033         * Whether the given {@linkplain MethodParameter method parameter} is
034         * supported by this resolver.
035         * @param parameter the method parameter to check
036         * @return {@code true} if this resolver supports the supplied parameter;
037         * {@code false} otherwise
038         */
039        boolean supportsParameter(MethodParameter parameter);
040
041        /**
042         * Resolves a method parameter into an argument value from a given message.
043         * @param parameter the method parameter to resolve.
044         * This parameter must have previously been passed to
045         * {@link #supportsParameter(org.springframework.core.MethodParameter)}
046         * which must have returned {@code true}.
047         * @param message the currently processed message
048         * @return the resolved argument value, or {@code null}
049         * @throws Exception in case of errors with the preparation of argument values
050         */
051        @Nullable
052        Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception;
053
054}