I want to map specific types to trigger Spring methods,
I save Map of Function Interfaces by key, the functions will call Spring services method, but I have an issue that it must be static, e.g.:
private Map<Pair<Type, Boolean>, Function<User, Boolean>> functionInterfaces = new HashMap<>();
{
functionInterfaces .put(Pair.of(Type.MY_TYPE, Boolean.TRUE), MySpringService::myTypeMethod);
}
So my method must be static
public static boolean myTypeMethod(User user)
Should I load Spring bean statically in order to call static method:
private static final MySpringService mySpringService = ApplicationInitializer.getAppContext().getBean(MySpringService.class);
Or is there a better without static initializing Spring beans?