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

## Class TargetSelector

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

    public final class TargetSelector
    extends java.lang.Object

Utility class for parsing selectors

### Nested Class Summary

Nested Classes
`static class` `TargetSelector.Result<TNode>` Query result struct

### Method Summary

All Methods Static Methods Concrete Methods
`static java.util.Set<ITargetSelector>` `parse​(java.lang.Iterable<?> selectors, ISelectorContext context)` Parse a collection of target selector representations (strings, annotations, class literals) into selectors.
`static java.util.Set<ITargetSelector>` `parse​(java.lang.Iterable<?> selectors, ISelectorContext context, java.util.Set<ITargetSelector> parsed)` Parse a collection of target selector representations (strings, annotations, class literals) into selectors and store them in the provided collection.
`static ITargetSelector` `parse​(java.lang.String string, ISelectorContext context)` Parse a target selector from a string
`static ITargetSelector` `parse​(IAnnotationHandle annotation, ISelectorContext context)` Parse a target selector from the supplied annotation
`static java.util.Set<ITargetSelector>` `parseAndValidate​(java.lang.Iterable<?> selectors, ISelectorContext context)` Parse a collection of target selector representations (strings, annotations, class literals) into selectors.
`static ITargetSelector` `parseAndValidate​(java.lang.String string, ISelectorContext context)` Parse a target selector from a string and perform validation
`static ITargetSelector` `parseAndValidate​(IAnnotationHandle annotation, ISelectorContext context)` Parse a target selector from the supplied annotation and perform validation
`static java.lang.String` `parseName​(java.lang.String name, ISelectorContext context)` Parse a target selector from the supplied name, and then return the name of the match.
`static void` `register​(java.lang.Class<? extends ITargetSelectorDynamic> type, java.lang.String namespace)` Register a dynamic target selector class.
`static <TNode> TargetSelector.Result<TNode>` `run​(java.lang.Iterable<ITargetSelector> selector, java.lang.Iterable<ElementNode<TNode>> nodes)` Run query on supplied target nodes
`static <TNode> TargetSelector.Result<TNode>` `run​(ITargetSelector selector, java.lang.Iterable<ElementNode<TNode>> nodes)` Run query on supplied target nodes

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

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

### Method Detail

#### register

    public static void register​(java.lang.Class<? extends ITargetSelectorDynamic> type,
                                java.lang.String namespace)

Register a dynamic target selector class. The supplied class must be decorated with an `ITargetSelectorDynamic.SelectorId` annotation for registration to succeed.

Parameters:
  `type` - ITargetSelectorDynamic to register
  `namespace` - namespace for SelectorId

#### parseAndValidate

    public static ITargetSelector parseAndValidate​(IAnnotationHandle annotation,
                                                   ISelectorContext context)
                                            throws InvalidSelectorException

Parse a target selector from the supplied annotation and perform validation

Parameters:
  `annotation` - Annotation to parse target selector from
  `context` - Context to use for reference mapping
Returns:
  parsed target selector
Throws:
  `InvalidSelectorException`

#### parseAndValidate

    public static ITargetSelector parseAndValidate​(java.lang.String string,
                                                   ISelectorContext context)
                                            throws InvalidSelectorException

Parse a target selector from a string and perform validation

Parameters:
  `string` - String to parse target selector from
  `context` - Context to use for reference mapping
Returns:
  parsed target selector
Throws:
  `InvalidSelectorException`

#### parseAndValidate

    public static java.util.Set<ITargetSelector> parseAndValidate​(java.lang.Iterable<?> selectors,
                                                                  ISelectorContext context)
                                                           throws InvalidSelectorException

Parse a collection of target selector representations (strings, annotations, class literals) into selectors.

Parameters:
  `selectors` - Selectors to parse
  `context` - Selection context
Returns:
  parsed collection of selectors, uses LinkedHashSet to preserve parse ordering
Throws:
  `InvalidSelectorException`

#### parse

    public static java.util.Set<ITargetSelector> parse​(java.lang.Iterable<?> selectors,
                                                       ISelectorContext context)

Parse a collection of target selector representations (strings, annotations, class literals) into selectors.

Parameters:
  `selectors` - Selectors to parse
  `context` - Selection context
Returns:
  parsed collection of selectors, uses LinkedHashSet to preserve parse ordering

#### parse

    public static java.util.Set<ITargetSelector> parse​(java.lang.Iterable<?> selectors,
                                                       ISelectorContext context,
                                                       java.util.Set<ITargetSelector> parsed)

Parse a collection of target selector representations (strings, annotations, class literals) into selectors and store them in the provided collection.

Parameters:
  `selectors` - Selectors to parse
  `context` - Selection context
  `parsed` - Collection to add parsed selectors to, initialised as a LinkedHashSet if null
Returns:
  the same collection passed in via the `parsed` parameter, for convenience

#### parse

    public static ITargetSelector parse​(IAnnotationHandle annotation,
                                        ISelectorContext context)

Parse a target selector from the supplied annotation

Parameters:
  `annotation` - String to parse target selector from
  `context` - Context to use for reference mapping
Returns:
  parsed target selector

#### parse

    public static ITargetSelector parse​(java.lang.String string,
                                        ISelectorContext context)

Parse a target selector from a string

Parameters:
  `string` - String to parse target selector from
  `context` - Context to use for reference mapping
Returns:
  parsed target selector

#### parseName

    public static java.lang.String parseName​(java.lang.String name,
                                             ISelectorContext context)

Parse a target selector from the supplied name, and then return the name of the match. This is used mainly to remap input names in the same context as a selector without needing the selector itself. If the supplied name does not successfully parse to a name-based selector, then the name is returned unchanged.

Parameters:
  `name` - Name to parse
  `context` - Mixin context
Returns:
  remapped name or original name

#### run

    public static <TNode> TargetSelector.Result<TNode> run​(ITargetSelector selector,
                                                           java.lang.Iterable<ElementNode<TNode>> nodes)

Run query on supplied target nodes

Type Parameters:
  `TNode` - Node type
Parameters:
  `selector` - Target selector
  `nodes` - Node collection to enumerate
Returns:
  query result

#### run

    public static <TNode> TargetSelector.Result<TNode> run​(java.lang.Iterable<ITargetSelector> selector,
                                                           java.lang.Iterable<ElementNode<TNode>> nodes)

Run query on supplied target nodes

Type Parameters:
  `TNode` - Node type
Parameters:
  `selector` - Target selector
  `nodes` - Node collection to enumerate
Returns:
  query result