Interface Extractor<A>

Type Parameters:
A - the type of extracted data
All Known Implementing Classes:
Theme, Variable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Generated(generator="eu.bandm.tools.expander", version="", timestamp="2026-01-12T17:56:36") @FunctionalInterface public interface Extractor<A>
Base interface for all extractors.

An extractor is a view on a pattern which can be used to extract data after a successful match.

Patterns and extractors are dual concepts: Whereas patterns serve as consumers of target objects, extractors serve as suppliers of the extracted data.

  • Method Summary

    Modifier and Type
    Method
    Description
    default <B> Pattern<B>
    bind(Pattern<? super B> root, Pattern<? super A> sub)
    Returns a pattern that effectively substitutes a subpattern for this extractor in a given root pattern.
    default <B> List<A>
    eagerBindings(Pattern<B> root, B target)
    Returns a collection of values bound to this extractor by all matches of a patterns for a target.
    Returns the extracted data value.
    default <B> Iterable<A>
    lazyBindings(Pattern<? super B> root, B target)
    Returns a lazy enumeration of values bound to this extractor by all matches of a patterns for a target.
    default <B> Stream<A>
    stream(Pattern<? super B> root, B target)
    Returns a stream of values bound to this extractor by all matches of a patterns for a target.
  • Method Details

    • getValue

      A getValue()
      Returns the extracted data value.

      The result is unspecified if the pattern viewed by this extractor is not in the state after a successful match.

      Returns:
      the extracted data value
    • eagerBindings

      default <B> List<A> eagerBindings(Pattern<B> root, B target)
      Returns a collection of values bound to this extractor by all matches of a patterns for a target.

      In contrast to lazyBindings(Pattern, Object), the alternative successful matches are exhausted before this method returns.

      Type Parameters:
      B - the target type of objects to match against
      Parameters:
      root - the pattern to match
      target - the object to match against
      Returns:
      the values bound by this extractor on all successive matching attempts of root against target, in order. The resulting List object is not shared, and may be used and modified freely by the caller.
      Throws:
      NullPointerException - if root is null
      See Also:
    • lazyBindings

      default <B> Iterable<A> lazyBindings(Pattern<? super B> root, B target)
      Returns a lazy enumeration of values bound to this extractor by all matches of a patterns for a target.

      In contrast to eagerBindings(Pattern, Object), the alternative successful matches are effected lazily on demand.

      Type Parameters:
      B - the target type of objects to match against
      Parameters:
      root - the pattern to match
      target - the object to match against
      Returns:
      the values bound by this extractor on all successive matching attempts of root against target, in order.
      Throws:
      NullPointerException - if root is null
      See Also:
    • stream

      default <B> Stream<A> stream(Pattern<? super B> root, B target)
      Returns a stream of values bound to this extractor by all matches of a patterns for a target.
      Type Parameters:
      B - the target type of objects to match against
      Parameters:
      root - the pattern to match
      target - the object to match against
      Returns:
      the stream of values bound by this extractor on all successive matching attempts of root against target, in order.
      Throws:
      NullPointerException - if root is null
      See Also:
    • bind

      default <B> Pattern<B> bind(Pattern<? super B> root, Pattern<? super A> sub)
      Returns a pattern that effectively substitutes a subpattern for this extractor in a given root pattern.

      The structure of the root pattern is not analyzed. Instead, its bindings to this extractor are enumerated (as in lazyBindings(Pattern, Object)) and matched successively with the sub pattern.

      Type Parameters:
      B - the target type of objects to match against
      Parameters:
      root - the root pattern to substitute in. Substitution has unspecified effect if root does not bind this extractor.
      sub - the subpattern to substitute
      Returns:
      a pattern that effectively substitutes sub for this extractor in root
      Throws:
      NullPointerException - if root or sub is null
      See Also: