`ExtraModelKey` has no `equals` or `hashCode`
sylv256 opened this issue ยท 2 comments
Description
ExtraModelKey has no equals or hashCode methods meaning HashMap differentiates only by == a.k.a. instance.
Reproduction
- Register an Extra Model.
- Get the model using a new
ExtraModelKeywith the sameIdentifier. -
Null jumpscare!
Additional Details
This is a serious issue when dealing with extra models, because it means you must store your ExtraModelKeys somewhere as a constant.
ExtraModelKeys are intended to be stored as constants, and it is intentional that ExtraModelKeys are compared only by identity. The Supplier<String> is only meant for debug purposes. Is there some reason that you cannot store your keys as constants, or at least values in a map?
ExtraModelKeys are intended to be stored as constants, and it is intentional thatExtraModelKeys are compared only by identity. TheSupplier<String>is only meant for debug purposes. Is there some reason that you cannot store your keys as constants, or at least values in a map?
That's my bad. To be fair, it should be more abundantly clear that that's the intended behavior.