Check for a specific generic type

I have a variable of the type Supplier<? extends Item> and want to check if it’s Supplier<? extends BlockItem>. Is there a way to do that? instanceOf doesn’t seem to work according to IntelliJ. Minecraft forge 1.16.5 so java 8.
8 Replies
JavaBot
JavaBot14mo ago
This post has been reserved for your question.
Hey @blockgoblin31! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
blockgoblin31
blockgoblin31OP14mo ago
For context as to what I’m doing I have a function to register a block item from a block but it needs to be delayed from the last function that has the actual block, but I’m trying to make a HashMap keying the blocks to their item in case I need that at some point So I’d like to be able to retrieve the block from the BlockItem But the same function is used for non block items
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
blockgoblin31
blockgoblin31OP14mo ago
Probably, I was just giving context on how I came up with my question. My question is basically is there a way to check the type of a generic if I have a variable of type X<? extends T> Basically can I check if that variable is an instance of X<? extends Y> where Y extends T
Kyo-chan
Kyo-chan14mo ago
I'm sure you understand that in the case of List it is impossible by definition So it may possible with your particular generic type, but in general it's not
blockgoblin31
blockgoblin31OP14mo ago
Ok thank you
JavaBot
JavaBot14mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot14mo ago
Post Closed
This post has been closed by <@501514065068294154>.

Did you find this page helpful?