Class ObservablePayloadSegmentDecorator<T>

  • Type Parameters:
    T - The type of the payload.
    All Implemented Interfaces:
    Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.DecorateeAccessor<org.refcodes.serial.PayloadSegment<T>>, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<T>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<T,​org.refcodes.serial.PayloadTransmission<T>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<T>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<T>, org.refcodes.observer.Observable<PayloadObserver<T>>, org.refcodes.serial.DecoratorSegment<org.refcodes.serial.PayloadSegment<T>>, ObservablePayloadSegment<T>, ObservablePayloadTransmission<T>, org.refcodes.serial.PayloadSegment<T>, org.refcodes.serial.PayloadTransmission<T>, org.refcodes.serial.Segment, org.refcodes.serial.Transmission

    public class ObservablePayloadSegmentDecorator<T>
    extends Object
    implements ObservablePayloadSegment<T>, org.refcodes.serial.DecoratorSegment<org.refcodes.serial.PayloadSegment<T>>
    The ObservablePayloadSegment class enriches a PayloadSegment decoratee with observer functionality as of the ObservablePayloadSegment interface. In case the decoratee was updated as of receiveFrom(InputStream, OutputStream) or Segment.fromTransmission(Sequence) or the like, a PayloadEvent is fired. Attention: It is not fired upon calling setPayload(Object)!
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor

        org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.DecorateeAccessor

        org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE extends Object,​B extends org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE,​B>>, org.refcodes.mixin.DecorateeAccessor.DecorateeMutator<DECORATEE extends Object>, org.refcodes.mixin.DecorateeAccessor.DecorateeProperty<DECORATEE extends Object>
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor

        org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthProperty
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.PayloadAccessor

        org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P extends Object,​B extends org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P,​B>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<P extends Object>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<P extends Object>
      • Nested classes/interfaces inherited from interface org.refcodes.serial.Segment

        org.refcodes.serial.Segment.SegmentMixin
      • Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission

        org.refcodes.serial.Transmission.TransmissionMixin
    • Constructor Summary

      Constructors 
      Constructor Description
      ObservablePayloadSegmentDecorator​(org.refcodes.serial.PayloadSegment<T> aDecoratee)
      Constructs a ObservablePayloadSegment wrapping the given PayloadSegment decoratee and using a default ExecutorService and dispatching events in sequentially (as of ExecutionStrategy.SEQUENTIAL).
      ObservablePayloadSegmentDecorator​(org.refcodes.serial.PayloadSegment<T> aDecoratee, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy)
      Constructs a ObservablePayloadSegment wrapping the given PayloadSegment decoratee and using the provided ExecutorService when dispatching events in parallel (as of ExecutionStrategy.PARALLEL and ExecutionStrategy.JOIN) and using the given ExecutionStrategy when dispatching the events.
      ObservablePayloadSegmentDecorator​(org.refcodes.serial.PayloadSegment<T> aDecoratee, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy)
      Constructs a ObservablePayloadSegment wrapping the given PayloadSegment decoratee and using the provided ExecutionStrategy when dispatching the events.
    • Constructor Detail

      • ObservablePayloadSegmentDecorator

        public ObservablePayloadSegmentDecorator​(org.refcodes.serial.PayloadSegment<T> aDecoratee)
        Constructs a ObservablePayloadSegment wrapping the given PayloadSegment decoratee and using a default ExecutorService and dispatching events in sequentially (as of ExecutionStrategy.SEQUENTIAL).
        Parameters:
        aDecoratee - The decoratee to be wrapped by the observable decorator.
      • ObservablePayloadSegmentDecorator

        public ObservablePayloadSegmentDecorator​(org.refcodes.serial.PayloadSegment<T> aDecoratee,
                                                 org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy)
        Constructs a ObservablePayloadSegment wrapping the given PayloadSegment decoratee and using the provided ExecutionStrategy when dispatching the events.
        Parameters:
        aDecoratee - The decoratee to be wrapped by the observable decorator.
        aExecutionStrategy - the execution strategy to use when dispatching events.
      • ObservablePayloadSegmentDecorator

        public ObservablePayloadSegmentDecorator​(org.refcodes.serial.PayloadSegment<T> aDecoratee,
                                                 ExecutorService aExecutorService,
                                                 org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy)
        Constructs a ObservablePayloadSegment wrapping the given PayloadSegment decoratee and using the provided ExecutorService when dispatching events in parallel (as of ExecutionStrategy.PARALLEL and ExecutionStrategy.JOIN) and using the given ExecutionStrategy when dispatching the events.
        Parameters:
        aDecoratee - The decoratee to be wrapped by the observable decorator.
        aExecutorService - the executor service to use when dispatching events.
        aExecutionStrategy - the execution strategy to use when dispatching events.
    • Method Detail

      • fromTransmission

        public int fromTransmission​(org.refcodes.serial.Sequence aSequence,
                                    int aOffset)
                             throws org.refcodes.serial.TransmissionException
        Specified by:
        fromTransmission in interface org.refcodes.serial.Segment
        Throws:
        org.refcodes.serial.TransmissionException
      • receiveFrom

        public void receiveFrom​(InputStream aInputStream,
                                OutputStream aReturnStream)
                         throws IOException,
                                org.refcodes.serial.TransmissionException
        Specified by:
        receiveFrom in interface org.refcodes.serial.Segment
        Throws:
        IOException
        org.refcodes.serial.TransmissionException
      • getLength

        public int getLength()
        Specified by:
        getLength in interface org.refcodes.mixin.LengthAccessor
        Specified by:
        getLength in interface org.refcodes.serial.Transmission
      • toSequence

        public org.refcodes.serial.Sequence toSequence()
        Specified by:
        toSequence in interface org.refcodes.serial.Transmission
      • toSchema

        public org.refcodes.serial.Schema toSchema()
        Specified by:
        toSchema in interface org.refcodes.serial.Transmission
      • toSimpleTypeMap

        public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
        Specified by:
        toSimpleTypeMap in interface org.refcodes.serial.Transmission
      • withPayload

        public org.refcodes.serial.PayloadTransmission<T> withPayload​(T aValue)
        Specified by:
        withPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder<T,​org.refcodes.serial.PayloadTransmission<T>>
      • getPayload

        public T getPayload()
        Specified by:
        getPayload in interface org.refcodes.mixin.PayloadAccessor<T>
      • setPayload

        public void setPayload​(T aValue)
        Specified by:
        setPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadMutator<T>
      • getDecoratee

        public org.refcodes.serial.PayloadSegment<T> getDecoratee()
        Specified by:
        getDecoratee in interface org.refcodes.mixin.DecorateeAccessor<T>
      • getAlias

        public String getAlias()
        Specified by:
        getAlias in interface org.refcodes.mixin.AliasAccessor
      • hasObserverSubscription

        public boolean hasObserverSubscription​(PayloadObserver<T> aObserver)
        Specified by:
        hasObserverSubscription in interface org.refcodes.observer.Observable<T>
      • subscribeObserver

        public boolean subscribeObserver​(PayloadObserver<T> aObserver)
        Specified by:
        subscribeObserver in interface org.refcodes.observer.Observable<T>
      • unsubscribeObserver

        public boolean unsubscribeObserver​(PayloadObserver<T> aObserver)
        Specified by:
        unsubscribeObserver in interface org.refcodes.observer.Observable<T>