Enum Class InvocationStrategy
- All Implemented Interfaces:
Serializable,Comparable<InvocationStrategy>,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIf multiple methods match, then all matching methods will be invoked in sequence (notice: the order of the methods called is not deterministic)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. -
Method Summary
Modifier and TypeMethodDescriptionstatic InvocationStrategyReturns the enum constant of this class with the specified name.static InvocationStrategy[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
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 Details
-
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
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 nameNullPointerException- if the argument is null
-