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.web.method.annotation;
018
019import org.springframework.beans.TypeMismatchException;
020import org.springframework.core.MethodParameter;
021
022/**
023 * A TypeMismatchException raised while resolving a controller method argument.
024 * Provides access to the target {@link org.springframework.core.MethodParameter
025 * MethodParameter}.
026 *
027 * @author Rossen Stoyanchev
028 * @since 4.2
029 */
030@SuppressWarnings("serial")
031public class MethodArgumentTypeMismatchException extends TypeMismatchException {
032
033        private final String name;
034
035        private final MethodParameter parameter;
036
037
038        public MethodArgumentTypeMismatchException(Object value, Class<?> requiredType,
039                        String name, MethodParameter param, Throwable cause) {
040
041                super(value, requiredType, cause);
042                this.name = name;
043                this.parameter = param;
044        }
045
046
047        /**
048         * Return the name of the method argument.
049         */
050        public String getName() {
051                return this.name;
052        }
053
054        /**
055         * Return the target method parameter.
056         */
057        public MethodParameter getParameter() {
058                return this.parameter;
059        }
060
061}