Class EventStreamUtils


  • public class EventStreamUtils
    extends Object
    Utils for event streaming code generation.
    • Method Detail

      • getEventStreamInRequest

        public static ShapeModel getEventStreamInRequest​(ShapeModel requestShape)
        Get eventstream member from a request shape model. If shape doesn't have any eventstream member, throw an IllegalStateException.
        Parameters:
        requestShape - request shape of an operation
        Returns:
        eventstream member (shape with "eventstream" trait set to true) in the request shape. If there is no eventstream member, thrown IllegalStateException.
      • getEventStreamInResponse

        public static ShapeModel getEventStreamInResponse​(ShapeModel responseShape)
        Get eventstream member from a response shape model. If shape doesn't have any eventstream member, throw an IllegalStateException.
        Parameters:
        responseShape - response shape of an operation
        Returns:
        eventstream member (shape with "eventstream" trait set to true) in the response shape. If there is no eventstream member, thrown IllegalStateException.
      • getBaseEventStreamShape

        public static Optional<ShapeModel> getBaseEventStreamShape​(IntermediateModel model,
                                                                   ShapeModel eventShape)
        Returns the event stream ShapeModel that contains the given event.
        Parameters:
        model - Intermediate model
        eventShape - shape with "event: true" trait
        Returns:
        the event stream shape (eventstream: true) that contains the given event, or an empty optional if the C2J shape is marked as an event but the intermediate model representation is not used by an event stream
      • getEvents

        public static Stream<MemberModel> getEvents​(ShapeModel eventStreamShape)
        Returns the stream of event members ('event: true') excluding exceptions from the input event stream shape ('eventstream: true').
      • getEventMembers

        public static Stream<MemberModel> getEventMembers​(ShapeModel eventStreamShape)
        Returns the stream of event members ('event: true') excluding exceptions from the input event stream shape ('eventstream: true').
      • findOperationsWithEventStream

        public static Collection<OperationModel> findOperationsWithEventStream​(IntermediateModel model,
                                                                               ShapeModel eventStreamShape)
        Returns the all operations that contain the given event stream shape. The event stream can be in operation request or response shape.
      • doesShapeContainsEventStream

        public static boolean doesShapeContainsEventStream​(ShapeModel parentShape,
                                                           ShapeModel childEventStreamShape)
        Returns true if the #childEventStreamShape is a member of the #parentShape. Otherwise false.
      • isRequestEvent

        public static boolean isRequestEvent​(IntermediateModel model,
                                             ShapeModel eventShape)
        Returns true if the given event shape is a sub-member of any operation request.
      • isEventStreamParentModel

        public static boolean isEventStreamParentModel​(ShapeModel shapeModel)
        Returns:
        true if the provide model is a request/response shape model that contains event stream shape. Otherwise return false.