Supplier alternative
Hey! I have some optional dependencies in my
pom.xml
(scope: provided).
Now for each dependency I have a Hook class, which I would like to create an object of if the dependency is found.
The following has bee confirmed to work:
While this works, it comes at the cost of having a bunch of code when handling multiple dependencies.
So what I came up with instead is:
This cleans up my code base quite a bit, however, this will cause a java.lang.NoClassDefFoundError
, which I believe is caused by the static reference of the hook?
Can someone help me figure out an alternative? Any help is greatly appreciated^^6 Replies
⌛
This post has been reserved for your question.
Hey @Aze! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
It seems the function gets executed immediately, and the get method only returns the result. Is there an alternative that only executes the function on method call?
Use reflection
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
same issue
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.