Package org.springframework.aop.support

# Class NameMatchMethodPointcut

java.lang.Object
org.springframework.aop.support.StaticMethodMatcher
org.springframework.aop.support.StaticMethodMatcherPointcut
org.springframework.aop.support.NameMatchMethodPointcut

All Implemented Interfaces:
  `Serializable`, `MethodMatcher`, `Pointcut`

public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable
Pointcut bean for simple method name matches, as an alternative to regular expression patterns.

Each configured method name can be an exact method name or a method name pattern (see `isMatch(String, String)` for details on the supported pattern styles).

Does not handle overloaded methods: all methods with a given name will be eligible.

Since:
  11.02.2004
Author:
  Juergen Hoeller, Rod Johnson, Rob Harrop, Sam Brannen
See Also:
  - `isMatch(java.lang.String, java.lang.String)`
  - `JdkRegexpMethodPointcut`
  - Serialized Form

## Field Summary

### Fields inherited from interface org.springframework.aop.MethodMatcher

`TRUE`

### Fields inherited from interface org.springframework.aop.Pointcut

`TRUE`

## Constructor Summary

Constructors
Constructor
Description
`NameMatchMethodPointcut()`

## Method Summary

Modifier and Type
Method
Description
`NameMatchMethodPointcut`
`addMethodName(String mappedNamePattern)`
Add another method name pattern, in addition to those already configured.
`boolean`
`equals(Object other)`
`int`
`hashCode()`
`protected boolean`
`isMatch(String methodName, String mappedNamePattern)`
Determine if the given method name matches the mapped name pattern.
`boolean`
`matches(Method method, Class<?> targetClass)`
Perform static checking to determine whether the given method matches.
`void`
`setMappedName(String mappedNamePattern)`
Convenience method for configuring a single method name pattern.
`void`
`setMappedNames(String... mappedNamePatterns)`
Set the method name patterns defining methods to match.
`String`
`toString()`

### Methods inherited from class org.springframework.aop.support.StaticMethodMatcherPointcut

`getClassFilter, getMethodMatcher, setClassFilter`

### Methods inherited from class org.springframework.aop.support.StaticMethodMatcher

`isRuntime, matches`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### NameMatchMethodPointcut

public NameMatchMethodPointcut()

## Method Details

### setMappedName

public void setMappedName(String mappedNamePattern)
Convenience method for configuring a single method name pattern.

Use either this method or `setMappedNames(String...)`, but not both.

See Also:
  - `setMappedNames(java.lang.String...)`

### setMappedNames

public void setMappedNames(String... mappedNamePatterns)
Set the method name patterns defining methods to match.

Matching will be the union of all these; if any match, the pointcut matches.

See Also:
  - `setMappedName(String)`

### addMethodName

public NameMatchMethodPointcut addMethodName(String mappedNamePattern)
Add another method name pattern, in addition to those already configured.

Like the "set" methods, this method is for use when configuring proxies, before a proxy is used.

NOTE: This method does not work after the proxy is in use, since advice chains will be cached.

Parameters:
  `mappedNamePattern` - the additional method name pattern
Returns:
  this pointcut to allow for method chaining
See Also:
  - `setMappedNames(String...)`
  - `setMappedName(String)`

### matches

public boolean matches(Method method, Class<?> targetClass)
Description copied from interface: `MethodMatcher`
Perform static checking to determine whether the given method matches.

If this method returns `false` or if `MethodMatcher.isRuntime()` returns `false`, no runtime check (i.e. no `MethodMatcher.matches(Method, Class, Object[])` call) will be made.

Specified by:
  `matches` in interface `MethodMatcher`
Parameters:
  `method` - the candidate method
  `targetClass` - the target class
Returns:
  whether this method matches statically

### isMatch

protected boolean isMatch(String methodName, String mappedNamePattern)
Determine if the given method name matches the mapped name pattern.

The default implementation checks for `xxx*`, `*xxx`, `*xxx*`, and `xxx*yyy` matches, as well as direct equality.

Can be overridden in subclasses.

Parameters:
  `methodName` - the method name to check
  `mappedNamePattern` - the method name pattern
Returns:
  `true` if the method name matches the pattern
See Also:
  - `PatternMatchUtils.simpleMatch(String, String)`

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`