MethodParams { public static boolean firstIsCommand(Method method) { checkNotNull(method); MethodParams params = of(method); if (params.size() == 0) { return false; } boolean result = CommandMessage.class.isAssignableFrom(params.type(0)); return result; } private  MethodParams(@Nullable ArgumentFilter filter, Class<?>... types); private  MethodParams(@Nullable ArgumentFilter filter, ImmutableList<Class<?>> params); static MethodParams of(SubscriberMethod method); static MethodParams of(Method method); int size(); Optional<ArgumentFilter> filter(); Class<?> type(int index); boolean is(TypeMatcher type); boolean are(Class<?>... types); boolean match(TypeMatcher... criteria); boolean match(List<TypeMatcher> criteria); static boolean firstIsCommand(Method method); @Override boolean equals(Object o); @Override int hashCode(); @SuppressWarnings("DuplicateStringLiteralInspection") // others also have the `filter` field. @Override String toString();  }
@Test @DisplayName("detect if the first method parameter is a Command message") void detectFirstCommandParameter() { assertTrue(firstIsCommand(singleParamCommand())); assertTrue(firstIsCommand(twoParamCommandAndCtx())); assertFalse(firstIsCommand(fiveParamMethodStringAnyEmptyInt32UserId())); }