Interface Selector
-
public interface SelectorMatches a set of shapes using a selector expression.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSelector.RunnerDeprecated.This class is no longer necessary.static classSelector.ShapeMatchRepresents a selector match found in the model.static classSelector.StartingContextStarting environment context object used when evaluating a selector.
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Deprecated Methods Modifier and Type Method Description default voidconsumeMatches(Model model, java.util.function.Consumer<Selector.ShapeMatch> shapeMatchConsumer)Matches a selector to a set of shapes and receives each matched shape with the variables that were set when the shape was matched.default voidconsumeMatches(Model model, Selector.StartingContext context, java.util.function.Consumer<Selector.ShapeMatch> shapeMatchConsumer)Matches a selector to a set of shapes and receives each matched shape with the variables that were set when the shape was matched.static SelectorfromNode(Node node)Creates a Selector from aNode.default java.util.stream.Stream<Selector.ShapeMatch>matches(Model model)Returns a stream ofSelector.ShapeMatchobjects for each match found in a model.default java.util.stream.Stream<Selector.ShapeMatch>matches(Model model, Selector.StartingContext startingContext)Returns a stream ofSelector.ShapeMatchobjects for each match found in a model.static Selectorparse(java.lang.String expression)Parses a selector expression.default Selector.Runnerrunner()Deprecated.default java.util.Set<Shape>select(Model model)Matches a selector to a model.default java.util.Set<Shape>select(Model model, Selector.StartingContext context)Matches a selector to a model.default java.util.stream.Stream<Shape>shapes(Model model)Returns a stream of shapes in a model that match the selector.default java.util.stream.Stream<Shape>shapes(Model model, Selector.StartingContext context)Returns a stream of shapes in a model that match the selector.
-
-
-
Field Detail
-
IDENTITY
static final Selector IDENTITY
A selector that always returns all provided values.
-
-
Method Detail
-
parse
static Selector parse(java.lang.String expression)
Parses a selector expression.- Parameters:
expression- Expression to parse.- Returns:
- Returns the parsed
Selector.
-
fromNode
static Selector fromNode(Node node)
Creates a Selector from aNode.- Parameters:
node- Node to parse.- Returns:
- Returns the created selector.
- Throws:
SourceException- on error.
-
select
default java.util.Set<Shape> select(Model model)
Matches a selector to a model.- Parameters:
model- Model used to resolve shapes with.- Returns:
- Returns the matching shapes.
-
select
default java.util.Set<Shape> select(Model model, Selector.StartingContext context)
Matches a selector to a model.- Parameters:
model- Model used to resolve shapes with.context- Selector starting environment context.- Returns:
- Returns the matching shapes.
-
consumeMatches
default void consumeMatches(Model model, java.util.function.Consumer<Selector.ShapeMatch> shapeMatchConsumer)
Matches a selector to a set of shapes and receives each matched shape with the variables that were set when the shape was matched.- Parameters:
model- Model to select shapes from.shapeMatchConsumer- Receives each matched shape and the vars available when the shape was matched.
-
consumeMatches
default void consumeMatches(Model model, Selector.StartingContext context, java.util.function.Consumer<Selector.ShapeMatch> shapeMatchConsumer)
Matches a selector to a set of shapes and receives each matched shape with the variables that were set when the shape was matched.- Parameters:
model- Model to select shapes from.context- Selector starting environment context.shapeMatchConsumer- Receives each matched shape and the vars available when the shape was matched.
-
shapes
default java.util.stream.Stream<Shape> shapes(Model model)
Returns a stream of shapes in a model that match the selector.- Parameters:
model- Model to match the selector against.- Returns:
- Returns a stream of matching shapes.
-
shapes
default java.util.stream.Stream<Shape> shapes(Model model, Selector.StartingContext context)
Returns a stream of shapes in a model that match the selector.- Parameters:
model- Model to match the selector against.context- Selector starting environment context.- Returns:
- Returns a stream of matching shapes.
-
matches
default java.util.stream.Stream<Selector.ShapeMatch> matches(Model model)
Returns a stream ofSelector.ShapeMatchobjects for each match found in a model.- Parameters:
model- Model to match the selector against.- Returns:
- Returns a stream of
ShapeMatchobjects.
-
matches
default java.util.stream.Stream<Selector.ShapeMatch> matches(Model model, Selector.StartingContext startingContext)
Returns a stream ofSelector.ShapeMatchobjects for each match found in a model.- Parameters:
model- Model to match the selector against.startingContext- Selector starting environment context.- Returns:
- Returns a stream of
ShapeMatchobjects.
-
runner
@Deprecated default Selector.Runner runner()
Deprecated.Creates a SelectorRunner, used to customize how a selector is executed.- Returns:
- Returns the created runner.
-
-