Class SinglePublicUseCaseMethodCaller<U>

  • Type Parameters:
    U - the use case type
    All Implemented Interfaces:
    Caller<U>

    public final class SinglePublicUseCaseMethodCaller<U>
    extends Object
    implements Caller<U>
    A Caller that locates the the only public method of the use case class and invokes it, whenever a request is received.
    • Constructor Detail

      • SinglePublicUseCaseMethodCaller

        public SinglePublicUseCaseMethodCaller()
    • Method Detail

      • singlePublicUseCaseMethodCaller

        public static <U> SinglePublicUseCaseMethodCaller<U> singlePublicUseCaseMethodCaller​(Class<U> useCaseClass)
        Factory method to create a new SinglePublicUseCaseMethodCaller.
        Type Parameters:
        U - the type of the use case
        Parameters:
        useCaseClass - the class of the use case to call
        Returns:
        the newly created SinglePublicUseCaseMethodCaller
        Throws:
        IllegalArgumentException - if not suitable method could be found
      • call

        public Object call​(U useCase,
                           Object event,
                           CallingContext callingContext)
                    throws Exception
        Description copied from interface: Caller
        Invokes the use case with the data from the event.
        Specified by:
        call in interface Caller<U>
        Parameters:
        useCase - the use case instance
        event - the data for the use case
        callingContext - contains objects for serialization or parameter injection
        Returns:
        the serialized return value
        Throws:
        Exception - all exceptions declared by the use case method are rethrown