Enum InvocationStrategy
- java.lang.Object
-
- java.lang.Enum<InvocationStrategy>
-
- dk.cloudcreate.essentials.shared.reflection.invocation.InvocationStrategy
-
- All Implemented Interfaces:
Serializable,Comparable<InvocationStrategy>
public enum InvocationStrategy extends Enum<InvocationStrategy>
Determines which among as set of matching methods are invoked
-
-
Enum Constant Summary
Enum Constants Enum Constant Description InvokeAllMatchesIf multiple methods match, then all matching methods will be invoked in sequence (notice: the order of the methods called is not deterministic)InvokeMostSpecificTypeMatchedIf 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.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InvocationStrategyvalueOf(String name)Returns the enum constant of this type with the specified name.static InvocationStrategy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 asOrderCreated, OrderShipped, OrderAccepted, etc.
Let's say theargumentobject is an instance ofOrderAcceptedand 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
method1andmethod3match on type of the argument instance (OrderAccepted), becauseOrderEvent(ofmethod1) match by hierarchy, andOrderAccepted(ofmethod3) match directly by type.
UsingInvokeMostSpecificTypeMatchedthen onlymethod3will be called, sinceOrderAcceptedis a more specific type than the more generic typeOrderEvent
-
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 asOrderCreated, OrderShipped, OrderAccepted, etc.
Let's say theargumentobject is an instance ofOrderAcceptedand 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
method1andmethod3match on type of the argument instance (OrderAccepted), becauseOrderEvent(ofmethod1) match by hierarchy, andOrderAccepted(ofmethod3) match directly by type.
UsingInvokeAllMatchesthen BOTHmethod1andmethod3will 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 nameNullPointerException- if the argument is null
-
-