java.lang.Object
java.lang.Enum<InvocationStrategy>
dk.cloudcreate.essentials.shared.reflection.invocation.InvocationStrategy
All Implemented Interfaces:
Serializable, Comparable<InvocationStrategy>, Constable

public enum InvocationStrategy extends Enum<InvocationStrategy>
Determines which among as set of matching methods are invoked
  • Enum Constant Details

    • 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 Details

    • values

      public static InvocationStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static InvocationStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null