Class TargetSelector
- java.lang.Object
-
- org.spongepowered.asm.mixin.injection.selectors.TargetSelector
-
public final class TargetSelector extends java.lang.ObjectUtility class for parsing selectors
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTargetSelector.Result<TNode>Query result struct
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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 ITargetSelectorparse(java.lang.String string, ISelectorContext context)Parse a target selector from a stringstatic ITargetSelectorparse(IAnnotationHandle annotation, ISelectorContext context)Parse a target selector from the supplied annotationstatic 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 ITargetSelectorparseAndValidate(java.lang.String string, ISelectorContext context)Parse a target selector from a string and perform validationstatic ITargetSelectorparseAndValidate(IAnnotationHandle annotation, ISelectorContext context)Parse a target selector from the supplied annotation and perform validationstatic java.lang.StringparseName(java.lang.String name, ISelectorContext context)Parse a target selector from the supplied name, and then return the name of the match.static voidregister(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 nodesstatic <TNode> TargetSelector.Result<TNode>run(ITargetSelector selector, java.lang.Iterable<ElementNode<TNode>> nodes)Run query on supplied target nodes
-
-
-
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 anITargetSelectorDynamic.SelectorIdannotation for registration to succeed.- Parameters:
type- ITargetSelectorDynamic to registernamespace- 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 fromcontext- 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 fromcontext- 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 parsecontext- 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 parsecontext- 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 parsecontext- Selection contextparsed- 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 fromcontext- 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 fromcontext- 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 parsecontext- 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 selectornodes- 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 selectornodes- Node collection to enumerate- Returns:
- query result
-
-