ArcanePlugins / Treasury

🏦 A powerful multi-platform library for next-level plugin integrations.
https://hangar.papermc.io/ArcanePlugins/Treasury
Other
56 stars 13 forks source link

`Account`: Change the return type of `retrievePermissionsMap` #252

Closed lokka30 closed 1 year ago

lokka30 commented 1 year ago

Issue

The return type of Account#retrievePermissionsMap is annoying, and in my opinion, unwarranted:

CompletableFuture<Response<Map<UUID, Set<Map.Entry<AccountPermission, TriState>>>>>

Potential Solutions

I'll update this post over time with some potential solutions:

Current Opinions


I would appreciate to hear the opinions of @MrIvanPlays, @yannicklamprecht, and anyone else who is interested in partaking in this discussion.

yannicklamprecht commented 1 year ago

Would rather do that like the following.

CompletableFuture<Response<Map<UUID, PermissionHolder>>> retrievePermissionMap()
lokka30 commented 1 year ago

Would rather do that like the following.

CompletableFuture<Response<Map<UUID, PermissionHolder>>> retrievePermissionMap()

I see the merit in keeping a UUID map present, if we go for the permission holder solution then I would also prefer this option over eliminating both maps.

lokka30 commented 1 year ago

Thank you for your response by the way. :)

MrIvanPlays commented 1 year ago

PermissionHolder has the potential of creating much bigger overhead rather than what is currently implemented. I don't understand what's your problem with the return type?

lokka30 commented 1 year ago

PermissionHolder has the potential of creating much bigger overhead rather than what is currently implemented. I don't understand what's your problem with the return type?

I can live with the unusual and verbose return type remaining (nesting a set of map entries inside a different map), though I'd like to see if it can be improved in any form before we make the choice final.

You're right about the overhead concern. What do you think about nesting the map instead of taking the weird side-road solution of using the set of map entries?

MrIvanPlays commented 1 year ago

the current solution allows for caching entries. each time you call map#entrySet (afaik) the set of entries is always generated, hence greater overload. the current solution is good in many ways, as it is much easier to loop through it rather looping through a nested map.

lokka30 commented 1 year ago

I greatly appreciate you providing your opinion on this matter, I'm still unsure myself which way to go, though as you insist that the current solution is adequate, I'll close this issue and we'll leave it as-is 🙂