001/* 002 * Copyright 2002-2018 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.core; 018 019import java.lang.reflect.Constructor; 020import java.lang.reflect.Method; 021 022import org.springframework.lang.Nullable; 023 024/** 025 * Interface to discover parameter names for methods and constructors. 026 * 027 * <p>Parameter name discovery is not always possible, but various strategies are 028 * available to try, such as looking for debug information that may have been 029 * emitted at compile time, and looking for argname annotation values optionally 030 * accompanying AspectJ annotated methods. 031 * 032 * @author Rod Johnson 033 * @author Adrian Colyer 034 * @since 2.0 035 */ 036public interface ParameterNameDiscoverer { 037 038 /** 039 * Return parameter names for a method, or {@code null} if they cannot be determined. 040 * <p>Individual entries in the array may be {@code null} if parameter names are only 041 * available for some parameters of the given method but not for others. However, 042 * it is recommended to use stub parameter names instead wherever feasible. 043 * @param method the method to find parameter names for 044 * @return an array of parameter names if the names can be resolved, 045 * or {@code null} if they cannot 046 */ 047 @Nullable 048 String[] getParameterNames(Method method); 049 050 /** 051 * Return parameter names for a constructor, or {@code null} if they cannot be determined. 052 * <p>Individual entries in the array may be {@code null} if parameter names are only 053 * available for some parameters of the given constructor but not for others. However, 054 * it is recommended to use stub parameter names instead wherever feasible. 055 * @param ctor the constructor to find parameter names for 056 * @return an array of parameter names if the names can be resolved, 057 * or {@code null} if they cannot 058 */ 059 @Nullable 060 String[] getParameterNames(Constructor<?> ctor); 061 062}