Package org.spongepowered.asm.mixin.injection.selectors

## Class MemberMatcher

- java.lang.Object
- - org.spongepowered.asm.mixin.injection.selectors.MemberMatcher

- All Implemented Interfaces:
    `ITargetSelector`

      public final class MemberMatcher
      extends java.lang.Object
      implements ITargetSelector

  A `Target Selector` which matches an element of candidate members using a regular expression. This selector is not remappable and is not suitable for use in obfuscated environments.

  Regular expressions for this selector should be enclosed in `/` as a delimiter character, and `\` characters must be escaped per normal Java conventions (eg. use `\\s` instead of `\s` since the backslash must be escaped). Forward slash (`/`) characters in the regex must be escaped as well to avoid being consumed as ending delimiters.

  By default the regex match is performed against the `name` of the candidate, to specify matching against `owner` or `desc`, each pattern should be prefixed with `owner=` or `desc=` outside the delimiting `/`.

  Some examples:

  >        // Matches candidates starting with "foo"
  >        /^foo/

  >        // Matches candidates ending with "Bar" and which take a single int
  >        /bar$/ desc=/^\\(I\\)/

  >        // The same example but with "name" explicitly specified (optional)
  >        name=/bar$/ desc=/^\\(I\\)/

  >        // Matches candidates whose name contains "Entity"
  >        /Entity/

  >        // Matches candidates whose owner contains "/google/", note the
  >        // escaping of the forward slash symbols
  >        owner=/\\/google\\//

  The `owner`, `name` and `desc` expressions can be provided in any order.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.spongepowered.asm.mixin.injection.selectors.ITargetSelector

      `ITargetSelector.Configure`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ITargetSelector` | `attach​(ISelectorContext context)` | Attach this selector to the specified context.
    `ITargetSelector` | `configure​(ITargetSelector.Configure request, java.lang.String... args)` | Configure and return a modified version of this selector by consuming the supplied arguments.
    `int` | `getMaxMatchCount()` | Maximum number of candidates this selector can match
    `int` | `getMinMatchCount()` | Minimum number of candidates this selector must match
    `<TNode> MatchResult` | `match​(ElementNode<TNode> node)` | Test whether this selector matches the supplied element node
    `ITargetSelector` | `next()` | Get the next target selector in this path (or `null` if this selector is the last selector in the chain.
    `static MemberMatcher` | `parse​(java.lang.String input, ISelectorContext context)` | Parse a MemberMatcher from the supplied input string.
    `java.lang.String` | `toString()` |
    `ITargetSelector` | `validate()` | Perform basic sanity-check validation of the selector, checks that the parsed out parameters are basically sane

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

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

- - ### Method Detail

    - #### parse

          public static MemberMatcher parse​(java.lang.String input,
                                            ISelectorContext context)

      Parse a MemberMatcher from the supplied input string.
      Parameters:
        `input` - Raw input string
        `context` - selector context
      Returns:
        parsed MemberMatcher

    - #### validate

          public ITargetSelector validate()
                                   throws InvalidSelectorException

      Description copied from interface: `ITargetSelector`
      Perform basic sanity-check validation of the selector, checks that the parsed out parameters are basically sane
      Specified by:
        `validate` in interface `ITargetSelector`
      Returns:
        fluent (this selector)
      Throws:
        `InvalidSelectorException` - if any sanity check fails

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### next

          public ITargetSelector next()

      Description copied from interface: `ITargetSelector`
      Get the next target selector in this path (or `null` if this selector is the last selector in the chain. Called at recurse points in the subject in order to match against the child subject.

      Can return null

      Specified by:
        `next` in interface `ITargetSelector`

    - #### configure

          public ITargetSelector configure​(ITargetSelector.Configure request,
                                           java.lang.String... args)

      Description copied from interface: `ITargetSelector`
      Configure and return a modified version of this selector by consuming the supplied arguments. Results from this method should be idempotent in terms of the configuration of the returned object, but do not have to necessarily return the same object if the callee already matches the supplied configuration, or if the requested mutation is not supported by the selector, though this is generally the case.

      In other words, calling `configure(Configure.ORPHAN)` when this object is already an orphan or does not support orphaning, may simply return this object, or might return an identically-configured copy.

      Must not return null, defaults to returning unmodified selector.

      Specified by:
        `configure` in interface `ITargetSelector`
      Parameters:
        `request` - Requested operation
        `args` - Configuration arguments
      Returns:
        Configured selector, may return this selector if the specified condition is already satisfied

    - #### attach

          public ITargetSelector attach​(ISelectorContext context)
                                 throws InvalidSelectorException

      Description copied from interface: `ITargetSelector`
      Attach this selector to the specified context. Should return this selector unmodified if all is well, or a new selector to be used for further processing of the supplied context. If the supplied context is invalid, an `InvalidSelectorException` is thrown.
      Specified by:
        `attach` in interface `ITargetSelector`
      Parameters:
        `context` - Context to attach to
      Returns:
        Attached selector
      Throws:
        `InvalidSelectorException`

    - #### getMinMatchCount

          public int getMinMatchCount()

      Description copied from interface: `ITargetSelector`
      Minimum number of candidates this selector must match
      Specified by:
        `getMinMatchCount` in interface `ITargetSelector`

    - #### getMaxMatchCount

          public int getMaxMatchCount()

      Description copied from interface: `ITargetSelector`
      Maximum number of candidates this selector can match
      Specified by:
        `getMaxMatchCount` in interface `ITargetSelector`

    - #### match

          public <TNode> MatchResult match​(ElementNode<TNode> node)

      Description copied from interface: `ITargetSelector`
      Test whether this selector matches the supplied element node
      Specified by:
        `match` in interface `ITargetSelector`
      Type Parameters:
        `TNode` - node type
      Parameters:
        `node` - node node to test
      Returns:
        true if this selector can match the supplied field