Class PrioritizedParameterNameDiscoverer

java.lang.Object
org.springframework.core.PrioritizedParameterNameDiscoverer
All Implemented Interfaces:
ParameterNameDiscoverer
Direct Known Subclasses:
DefaultParameterNameDiscoverer

public class PrioritizedParameterNameDiscoverer extends Object implements ParameterNameDiscoverer
ParameterNameDiscoverer implementation that tries several discoverer delegates in succession. Those added first in the addDiscoverer method have the highest priority. If one returns null, the next will be tried.

The default behavior is to return null if no discoverer matches.

Since:
2.0
Author:
Rod Johnson, Juergen Hoeller
  • Constructor Details

    • PrioritizedParameterNameDiscoverer

      public PrioritizedParameterNameDiscoverer()
  • Method Details

    • addDiscoverer

      public void addDiscoverer(ParameterNameDiscoverer pnd)
      Add a further ParameterNameDiscoverer delegate to the list of discoverers that this PrioritizedParameterNameDiscoverer checks.
    • getParameterNames

      @Nullable public String[] getParameterNames(Method method)
      Description copied from interface: ParameterNameDiscoverer
      Return parameter names for a method, or null if they cannot be determined.

      Individual entries in the array may be null if parameter names are only available for some parameters of the given method but not for others. However, it is recommended to use stub parameter names instead wherever feasible.

      Specified by:
      getParameterNames in interface ParameterNameDiscoverer
      Parameters:
      method - the method to find parameter names for
      Returns:
      an array of parameter names if the names can be resolved, or null if they cannot
    • getParameterNames

      @Nullable public String[] getParameterNames(Constructor<?> ctor)
      Description copied from interface: ParameterNameDiscoverer
      Return parameter names for a constructor, or null if they cannot be determined.

      Individual entries in the array may be null if parameter names are only available for some parameters of the given constructor but not for others. However, it is recommended to use stub parameter names instead wherever feasible.

      Specified by:
      getParameterNames in interface ParameterNameDiscoverer
      Parameters:
      ctor - the constructor to find parameter names for
      Returns:
      an array of parameter names if the names can be resolved, or null if they cannot