void (@NotNull Map<String, Object> methodReturnValues, @NotNull Class<?> listenerClass) { List<Method> declared = new ArrayList<>(ReflectionUtil.getClassPublicMethods(listenerClass)); for (final Map.Entry<String, Object> entry : methodReturnValues.entrySet()) { final String methodName = entry.getKey(); Method found = ContainerUtil.find(declared, m -> methodName.equals(m.getName())); assert found != null : "Method " + methodName + " must be declared in " + listenerClass; assert !found.getReturnType().equals(void.class) : "Method " + methodName + " must be non-void if you want to specify what its proxy should return"; Object returnValue = entry.getValue(); assert ReflectionUtil.boxType(found.getReturnType()).isAssignableFrom(returnValue.getClass()) : "You specified that method " + methodName + " proxy will return " + returnValue + " but its return type is " + found.getReturnType() + " which is incompatible with " + returnValue.getClass(); declared.remove(found); } for (Method method : declared) { assert method.getReturnType().equals(void.class) : "Method "+method+" returns "+method.getReturnType()+" and yet you didn't specify what its proxy should return"; } }