Bastian / bstats-metrics

The different bStats Metrics classes
https://bStats.org
MIT License
98 stars 114 forks source link

Add overload for SimplePie to accept pritimive boolean-typed callables #79

Closed 2008Choco closed 2 years ago

2008Choco commented 3 years ago

A common use for simple pie charts are just true/false pie slices and that can be quite awkward to define currently. This change adds a new FunctionalInterface which allows callers to return a primitive-typed boolean to more conveniently define true/false pie charts without having to use either a ternary or a call to toString().

metrics.addCustomChart(new SimplePie("alchema_integration", () -> String.valueOf(alchemaInstalled))); // Old
metrics.addCustomChart(new SimplePie("alchema_integration", () -> alchemaInstalled)); // New
Bastian commented 3 years ago

Thank you for the PR. :)

I'm not sure if this something that we really need. Calling String.valueOf(...) is really not that inconvenient and imo not worth the additional bloat in the Metrics classes. Additionally, I doubt that many people actually want to just display "true"/"false" but rather provide a custom text like "enabled"/"disabled" or whatever matches best for their use case.

Bastian commented 2 years ago

I'll close this PR as I don't believe that the additional bloat does justify the really small inconvenience for the user to call String.valueOf(...).

Thank you again for your time and sorry for not merging the PR