Enum InvocationStrategy

    • Enum Constant Detail

      • InvokeMostSpecificTypeMatched

        public static final InvocationStrategy InvokeMostSpecificTypeMatched
        If multiple methods match, then the method with the most specific type (in a type hierarchy) will be chosen as only a SINGLE method will be invoked.

        Example: Say we have a single class we have placed a set methods that can handle OrderEvent's, such as OrderCreated, OrderShipped, OrderAccepted, etc.
        Let's say the argument object is an instance of OrderAccepted and we're matching against the following methods

              @EventHandler
               private void method1(OrderEvent t) { ... }
        
              @EventHandler
               private void method2(OrderShipped t) { ... }
        
              @EventHandler
               private void method3(OrderAccepted t) { ... }
             

        In this case both method1 and method3 match on type of the argument instance (OrderAccepted), because OrderEvent (of method1) match by hierarchy, and OrderAccepted (of method3) match directly by type.
        Using InvokeMostSpecificTypeMatched then only method3 will be called, since OrderAccepted is a more specific type than the more generic type OrderEvent

      • InvokeAllMatches

        public static final InvocationStrategy InvokeAllMatches
        If multiple methods match, then all matching methods will be invoked in sequence (notice: the order of the methods called is not deterministic)

        Example: Say we have a single class we have placed a set methods that can handle OrderEvent's, such as OrderCreated, OrderShipped, OrderAccepted, etc.
        Let's say the argument object is an instance of OrderAccepted and we're matching against the following methods

              @EventHandler
               private void method1(OrderEvent t) { ... }
        
              @EventHandler
               private void method2(OrderShipped t) { ... }
        
              @EventHandler
               private void method3(OrderAccepted t) { ... }
             

        In this case both method1 and method3 match on type of the argument instance (OrderAccepted), because OrderEvent (of method1) match by hierarchy, and OrderAccepted (of method3) match directly by type.
        Using InvokeAllMatches then BOTH method1 and method3 will be called (notice: the order in which the methods will be called is not deterministic)

    • Method Detail

      • values

        public static InvocationStrategy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (InvocationStrategy c : InvocationStrategy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static InvocationStrategy valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null