Class ResultCollector

  • All Implemented Interfaces:
    java.util.function.Consumer<org.projectnessie.versioned.Result>

    public class ResultCollector
    extends java.lang.Object
    implements java.util.function.Consumer<org.projectnessie.versioned.Result>
    A collector for Results produced by the version store.

    Instances of this class are meant to be injected into version stores to collect results.

    The main reason why this functionality is not part of the EventService is that EventService is meant to be a singleton, while ResultCollector is meant to be instantiated per request, in order to capture the user principal that initiated the request, and the target repository id.

    • Constructor Summary

      Constructors 
      Constructor Description
      ResultCollector​(EventSubscribers subscribers, java.lang.String repositoryId, java.security.Principal user, java.util.function.Consumer<VersionStoreEvent> destination)
      Creates a new instance that forwards received Results to the given Consumer, allowing implementers to control how the event is delivered to the EventService.
      ResultCollector​(EventSubscribers subscribers, java.lang.String repositoryId, java.security.Principal user, EventService destination)
      Creates a new instance that forwards received Results to the given EventService synchronously.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(org.projectnessie.versioned.Result result)
      Called when a result is produced by the version store.
      protected void forwardToEventService​(VersionStoreEvent event)
      Forwards the received VersionStoreEvent to the destination for delivery to subscribers.
      protected boolean shouldProcess​(org.projectnessie.versioned.Result result)
      Returns true if the given Result should be processed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.Consumer

        andThen
    • Field Detail

      • repositoryId

        protected final java.lang.String repositoryId
      • user

        protected final java.security.Principal user
      • destination

        protected final java.util.function.Consumer<VersionStoreEvent> destination
    • Constructor Detail

      • ResultCollector

        public ResultCollector​(EventSubscribers subscribers,
                               java.lang.String repositoryId,
                               java.security.Principal user,
                               EventService destination)
        Creates a new instance that forwards received Results to the given EventService synchronously.
      • ResultCollector

        public ResultCollector​(EventSubscribers subscribers,
                               java.lang.String repositoryId,
                               java.security.Principal user,
                               java.util.function.Consumer<VersionStoreEvent> destination)
        Creates a new instance that forwards received Results to the given Consumer, allowing implementers to control how the event is delivered to the EventService.
    • Method Detail

      • accept

        public void accept​(org.projectnessie.versioned.Result result)
        Called when a result is produced by the version store.
        Specified by:
        accept in interface java.util.function.Consumer<org.projectnessie.versioned.Result>
      • shouldProcess

        protected boolean shouldProcess​(org.projectnessie.versioned.Result result)
        Returns true if the given Result should be processed.

        This acts as an early filter to remove results that are not relevant to any of the subscribers.

      • forwardToEventService

        protected void forwardToEventService​(VersionStoreEvent event)
        Forwards the received VersionStoreEvent to the destination for delivery to subscribers.