Package ch.njol.skript.util
Class Patterns<T>
java.lang.Object
ch.njol.skript.util.Patterns<T>
A helper class useful when an expression/condition/effect/etc. needs to associate additional data with each pattern.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptiongetInfo(int matchedPattern) Returns the typed objectPatternscorrelating tomatchedPattern.getMatchedPattern(T type, int arrayIndex) Retrieves the index of a specific matched pattern for the givetype, based on the providedarrayIndex.Integer @Nullable []getMatchedPatterns(T type) Retrieves all pattern indices that are associated withtype.String[]Returns an array of the registered patterns. 
- 
Constructor Details
- 
Patterns
 
 - 
 - 
Method Details
- 
getPatterns
Returns an array of the registered patterns. - 
getInfo
Returns the typed objectPatternscorrelating tomatchedPattern.- Parameters:
 matchedPattern- The pattern to get the data to as given inSyntaxElement.init(Expression[], int, Kleenean, ParseResult)- Returns:
 - The info associated with the matched pattern
 - Throws:
 ClassCastException- If the item in the source array is not of the requested type
 - 
getMatchedPatterns
Retrieves all pattern indices that are associated withtype.These indices represent the positions of matched patterns registered for the provided typed object.
- Parameters:
 type- The typed object to look up.- Returns:
 - An array of matched pattern indices, or 
nullif no patterns are registered for the given type. 
 - 
getMatchedPattern
Retrieves the index of a specific matched pattern for the givetype, based on the providedarrayIndex.This method looks up all matched pattern indices for the specified type and returns the index at
arrayIndex, if it exists.- Parameters:
 type- The object whose registered patterns should be retrieved.arrayIndex- The position in the matched pattern array to retrieve/- Returns:
 - An 
Optionalcontaining the matched pattern index at the specified position, orOptional.empty()if no patterns are registered fortypeor if the array does not contain enough elements. - See Also:
 
 
 -