Class GetSelector

  • All Implemented Interfaces:
    Comparable<Item>, Iterable<Item>, Debug, Display

    public final class GetSelector
    extends Selector
    A Selector that, when evaluated, searches all variables in its evaluation scope and yields the most recent Value that corresponds to key. Note that key itself can be an Expression, in which case it will be evaluated against stack prior to any concrete selection logic.
    • Constructor Detail

    • Method Detail

      • accessor

        public Value accessor()
      • then

        public Selector then()
        Description copied from class: Selector
        Returns the Selector that this Selector uses to match sub-selections.
        Specified by:
        then in class Selector
      • forSelected

        public <T> T forSelected​(Interpreter interpreter,
                                 Selectee<T> callback)
        Description copied from class: Selector
        Evaluates callback.selected against the Items that match this Selector's selection criteria. That is, it pushes such Items to interpreter, then invokes callback against it. To support chained Selectors, this is a recursive procedure that invokes forSelected through this.then wherever it exists (which it always does outside of IdentitySelector); we define "subselection" to be such an invocation.
        Specified by:
        forSelected in class Selector
        Returns:
        the result of executing callback from the context of the last Selector in the chain formed by Selector then fields.
      • andThen

        public Selector andThen​(Selector then)
        Description copied from class: Selector
        The means to chain Selectors. By intention, this is NOT a strict functional composition: for two Selectors s1 and s2, s1.andThen(s2) DOES NOT NECESSARILY return a new Selector s3 such that s3.evaluate(args) is equivalent to s2.evaluate(s1.evaluate(args)).

        The reason for this is that for Selectors like ChildrenSelector that yield (logical) collections, we wish to invoke the next Selector, say a GetSelector, against every result. Under strict functional rules, ChildrenSelector.andThen(someGetSelector).evaluate(args) would instead return at most one defined value regardless of the number of children.

        Specified by:
        andThen in class Selector
      • typeOrder

        public int typeOrder()
        Description copied from class: Item
        Returns the heterogeneous sort order of this Item. Used to impose a total order on the set of all items. When comparing two items of different types, the items order according to their typeOrder.
        Specified by:
        typeOrder in class Item
      • equals

        public boolean equals​(Object other)
        Specified by:
        equals in class Item
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class Item