Interface IntermediateEventRepresentation

All Known Implementing Classes:
InitialEventRepresentation, UpcastedEventRepresentation

public interface IntermediateEventRepresentation
Interface describing the intermediate representation of an event during upcasting.
Since:
3.0
Author:
Rene de Waele
  • Method Details

    • upcastPayload

      default <T> IntermediateEventRepresentation upcastPayload(SerializedType outputType, Class<T> expectedRepresentationType, Function<T,T> upcastFunction)
      Upcast the serialized payload of the event (leaving other aspects of the event the same).
      Type Parameters:
      T - The expected payload type before and after upcasting
      Parameters:
      outputType - The output type of the event after upcasting
      expectedRepresentationType - The type of the serialized payload required by the upcast function
      upcastFunction - The upcast function for the event's payload
      Returns:
      The intermediate representation of the event after upcasting
    • upcast

      <T> IntermediateEventRepresentation upcast(SerializedType outputType, Class<T> expectedRepresentationType, Function<T,T> upcastFunction, Function<MetaData,MetaData> metaDataUpcastFunction)
      Upcast the serialized payload of the event (leaving other aspects of the event the same).
      Type Parameters:
      T - The expected payload type before and after upcasting
      Parameters:
      outputType - The output type of the event after upcasting
      expectedRepresentationType - The type of the serialized payload required by the upcast function
      upcastFunction - The upcast function for the event's payload
      metaDataUpcastFunction - The upcast function for the event's metadata
      Returns:
      The intermediate representation of the event after upcasting
    • getType

      SerializedType getType()
      Returns the type and version of the data contained in this representation.
      Returns:
      the type and version of the represented data
    • getData

      SerializedObject<?> getData()
      Get the data of this representation. The type of the returned data should match that of getType().
      Returns:
      the data representation of the object
    • getData

      <D> SerializedObject<D> getData(Class<D> requiredType)
      Get the data of this representation. The type of the returned data will be converted to the given requiredType.
      Parameters:
      requiredType - the type to convert to
      Returns:
      the data representation of the object converted to the required type
    • getContentType

      default Class<?> getContentType()
      Returns the type of this representation's data.
      Returns:
      The type of this representation's data.
    • getMessageIdentifier

      String getMessageIdentifier()
      Returns the identifier of the message wrapping the object to upcast.
      Returns:
      the identifier of the message wrapping the object to upcast
    • getAggregateType

      Optional<String> getAggregateType()
      Returns the Type of the Aggregate to which the Event owning the object to upcast, was applied. This will return an empty Optional if the object being upcast was not contained in a DomainEventMessage.
      Returns:
      the Type of the Aggregate to which the Event was applied, or an empty Optional if not applicable
    • getAggregateIdentifier

      Optional<String> getAggregateIdentifier()
      Returns the Identifier of the Aggregate to which the Event owning the object to upcast, was applied. This will return an empty Optional if the object being upcast was not contained in a DomainEventMessage.
      Returns:
      the Identifier of the Aggregate to which the Event was applied, or an empty Optional if not applicable
    • getSequenceNumber

      Optional<Long> getSequenceNumber()
      Returns the sequence number of the event in the aggregate, or an empty Optional if the message wrapping the object being upcast does not contain a sequence number.
      Returns:
      the sequence number of the event in the aggregate, or an empty Optional if not applicable
    • getTrackingToken

      Optional<TrackingToken> getTrackingToken()
      Returns the tracking token of the event, or an empty Optional if the message wrapping the object being upcast does not contain a tracking token.
      Returns:
      the tracking token of the event, or an empty Optional if not applicable
    • getTimestamp

      Instant getTimestamp()
      Returns the timestamp at which the event was first created. Will return null if the object being upcast
      Returns:
      the timestamp at which the event was first created, if available
    • getMetaData

      Returns the meta data of the message wrapping the object being upcast. If the meta data is not available, or is in fact the subject of being upcast itself, this method returns null.
      Returns:
      the MetaData of the message wrapping the object to upcast, if available
    • canConvertDataTo

      boolean canConvertDataTo(Class<?> requiredType)
      Checks if the data can be converted to the given requiredType.
      Parameters:
      requiredType - the type to validate if the contained data can be converted to.
      Returns:
      true, if the intermediate representation's data can be converted to desired type, false otherwise