org.eclipse.viatra.addon.databinding.runtime.collection

## Class ObservablePatternMatchCollectionBuilder<M extends IPatternMatch>

- java.lang.Object
- - org.eclipse.viatra.addon.databinding.runtime.collection.ObservablePatternMatchCollectionBuilder<M>

-     public class ObservablePatternMatchCollectionBuilder<M extends IPatternMatch>
      extends java.lang.Object

  Builder API for observable pattern match collections (lists and sets). This builder can be used for setting up complex observable collections including filtering, comparator or converter. Existing matchers or rule engines are supported together with configuration from query specification or VIATRA Query engine.
  - Use the `create(org.eclipse.viatra.query.runtime.api.IQuerySpecification<? extends org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<M>>)` methods to initialize a builder with a given matcher or query specification.
  - Use the set methods (`setEngine(org.eclipse.viatra.query.runtime.api.ViatraQueryEngine)`,`setFilter(org.eclipse.viatra.transformation.evm.api.event.EventFilter<M>)`, `setComparator(java.util.Comparator<M>)`, `setConverter(java.util.function.Function<M, ?>)`) to configure the builder.
  - Finally, use the `buildList()` and `buildSet()` methods to create an observable list or set as required.
  The same builder can be used to build multiple observable collections and the configuration can be updated as needed. Each built observable will use the configuration available when the build method is invoked.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ObservablePatternMatchCollectionBuilder(IQuerySpecification<? extends ViatraQueryMatcher<M>> specification)`
    `protected` | `ObservablePatternMatchCollectionBuilder(ViatraQueryMatcher<M> matcher)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ObservablePatternMatchList<M>` | `buildList()` Builds an `ObservablePatternMatchList` based on the configuration set in the builder.
    `ObservablePatternMatchSet<M>` | `buildSet()` Builds an `ObservablePatternMatchSet` based on the configuration set in the builder.
    `static <M extends IPatternMatch> ObservablePatternMatchCollectionBuilder<M>` | `create(IQuerySpecification<? extends ViatraQueryMatcher<M>> specification)` Creates a builder for configuring an observable collection observing the match set of the given `IQuerySpecification`
    `static <M extends IPatternMatch> ObservablePatternMatchCollectionBuilder<M>` | `create(ViatraQueryMatcher<M> matcher)` Creates a builder for configuring an observable collection observing the match set of the given `ViatraQueryMatcher`.
    `ObservablePatternMatchCollectionBuilder<M>` | `setComparator(java.util.Comparator<M> comparator)` The given comparator is used to define the ordering between the elements in the built observable.
    `ObservablePatternMatchCollectionBuilder<M>` | `setConverter(java.util.function.Function<M,?> converter)` The given converter function is used on each match and the end result is put into the observable collection.
    `ObservablePatternMatchCollectionBuilder<M>` | `setEngine(RuleEngine engine)` Sets the given `RuleEngine` to be used as the engine of the built observable.
    `ObservablePatternMatchCollectionBuilder<M>` | `setEngine(ViatraQueryEngine engine)` Sets the given `ViatraQueryEngine` to be used as the engine of the built observable.
    `ObservablePatternMatchCollectionBuilder<M>` | `setFilter(java.util.Collection<M> multifilters, ViatraQueryFilterSemantics semantics)` Sets the given collection of (partial) matches as an event filter with the given semantics used by the built observable collection.
    `ObservablePatternMatchCollectionBuilder<M>` | `setFilter(EventFilter<M> filter)` Sets the event filter used by the built observable collection.
    `ObservablePatternMatchCollectionBuilder<M>` | `setFilter(M filter)` Sets the given (partial) match as an event filter used by the built observable collection.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ObservablePatternMatchCollectionBuilder

          protected ObservablePatternMatchCollectionBuilder(IQuerySpecification<? extends ViatraQueryMatcher<M>> specification)

    - #### ObservablePatternMatchCollectionBuilder

          protected ObservablePatternMatchCollectionBuilder(ViatraQueryMatcher<M> matcher)

  - ### Method Detail

    - #### create

          public static <M extends IPatternMatch> ObservablePatternMatchCollectionBuilder<M> create(IQuerySpecification<? extends ViatraQueryMatcher<M>> specification)

      Creates a builder for configuring an observable collection observing the match set of the given `IQuerySpecification`
      Parameters:
        `specification` - the `IQuerySpecification` used to create a matcher

    - #### create

          public static <M extends IPatternMatch> ObservablePatternMatchCollectionBuilder<M> create(ViatraQueryMatcher<M> matcher)

      Creates a builder for configuring an observable collection observing the match set of the given `ViatraQueryMatcher`.
      Parameters:
        `matcher` - the `ViatraQueryMatcher` to use as the source of the observable collection

    - #### setFilter

          public ObservablePatternMatchCollectionBuilder<M> setFilter(EventFilter<M> filter)

      Sets the event filter used by the built observable collection.

    - #### setFilter

          public ObservablePatternMatchCollectionBuilder<M> setFilter(M filter)

      Sets the given (partial) match as an event filter used by the built observable collection.

    - #### setFilter

          public ObservablePatternMatchCollectionBuilder<M> setFilter(java.util.Collection<M> multifilters,
                                                                      ViatraQueryFilterSemantics semantics)

      Sets the given collection of (partial) matches as an event filter with the given semantics used by the built observable collection.

    - #### setEngine

          public ObservablePatternMatchCollectionBuilder<M> setEngine(ViatraQueryEngine engine)

      Sets the given `ViatraQueryEngine` to be used as the engine of the built observable.

    - #### setEngine

          public ObservablePatternMatchCollectionBuilder<M> setEngine(RuleEngine engine)

      Sets the given `RuleEngine` to be used as the engine of the built observable.

    - #### setComparator

          public ObservablePatternMatchCollectionBuilder<M> setComparator(java.util.Comparator<M> comparator)

      The given comparator is used to define the ordering between the elements in the built observable.

    - #### setConverter

          public ObservablePatternMatchCollectionBuilder<M> setConverter(java.util.function.Function<M,?> converter)

      The given converter function is used on each match and the end result is put into the observable collection.
      Since:
        2.0

    - #### buildList

          public ObservablePatternMatchList<M> buildList()

      Builds an `ObservablePatternMatchList` based on the configuration set in the builder.

    - #### buildSet

          public ObservablePatternMatchSet<M> buildSet()

      Builds an `ObservablePatternMatchSet` based on the configuration set in the builder.