Class DefaultIncomingData<DATATYPE extends Data>

  • All Implemented Interfaces:
    IncomingData<DATATYPE>

    public class DefaultIncomingData<DATATYPE extends Data>
    extends java.lang.Object
    implements IncomingData<DATATYPE>
    The default incoming data implementation
    Author:
    bratseth
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(DATATYPE data)
      Adds new data without completing this
      void add​(java.util.List<DATATYPE> data)
      Adds new data without completing this
      void addLast​(DATATYPE data)
      Adds new data and marks this as completed
      void addLast​(java.util.List<DATATYPE> data)
      Adds new data and marks this as completed
      void addNewDataListener​(java.lang.Runnable listener, java.util.concurrent.Executor executor)
      Add a listener which will be invoked every time new data is added to this.
      void assignOwner​(DataList<DATATYPE> owner)
      Assigns the owner of this.
      com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> completed()
      Returns a future in which all the incoming data that will be produced in this is available.
      java.util.List<DATATYPE> drain()
      Gets and removes all the data currently available in this.
      DataList<DATATYPE> getOwner()
      Returns the owner (target DataList) of this.
      boolean isComplete()
      Returns whether the data in this is complete
      void markComplete()
      Marks this as completed and notify any listeners
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DefaultIncomingData

        public DefaultIncomingData()
        Creates an instance which must be assigned an owner after creation
    • Method Detail

      • assignOwner

        public final void assignOwner​(DataList<DATATYPE> owner)
        Assigns the owner of this. Throws an exception if the owner is already set.
      • getOwner

        public DataList<DATATYPE> getOwner()
        Description copied from interface: IncomingData
        Returns the owner (target DataList) of this. Note that accessing the owner from the thread producing incoming data is generally *not* thread safe.
        Specified by:
        getOwner in interface IncomingData<DATATYPE extends Data>
      • completed

        public com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> completed()
        Description copied from interface: IncomingData
        Returns a future in which all the incoming data that will be produced in this is available. Listeners on this are invoked on the thread producing the incoming data (or a thread spawned from it), which in general is separate from the thread using the data list. Hence, listeners on this even cannot in general assume that they may modify the data list or the request.

        The data is not drained into the owner of this by this method. That must be done by the thread using the data list.

        This return the list owning this for convenience.

        Specified by:
        completed in interface IncomingData<DATATYPE extends Data>
      • drain

        public java.util.List<DATATYPE> drain()
        Gets and removes all the data currently available in this. The returned list is a modifiable fresh instance owned by the caller.
        Specified by:
        drain in interface IncomingData<DATATYPE extends Data>
      • addNewDataListener

        public void addNewDataListener​(java.lang.Runnable listener,
                                       java.util.concurrent.Executor executor)
        Description copied from interface: IncomingData
        Add a listener which will be invoked every time new data is added to this. This listener may be invoked at any time in any thread, any thread synchronization is left to the listener itself
        Specified by:
        addNewDataListener in interface IncomingData<DATATYPE extends Data>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object