Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add toString methods to API interface implementations #942
I'm marking this issue for first-timers-only. That means that I will only accept a PR for this one from someone who's never contributed to open source before. This one is easy (but don't make that statement make you feel bad if you have a hard time with it, there's more to contributing to open source than changing lines of code, especially if it's your first time). I'll hold your hand through this if you need me to. :-)
We'd like to add
Similar implementations should be made for:
Feel free to do one, or multiple implementations! Comment below which one(s) you are doing to avoid stepping on someone else's toes.
Here are the steps to get a PR merged here.
General feedback since I've made the same comments on every PR so far...
Please keep the
In contrast, please keep "formatting logic" in the
Hey @dbwiddis , might I recommend that instead of manually creating toString() strings , why don't we just use the Apache commons toStringBuilder class ? It is designed specifically for this purpose . It will be consistent throughout .
Just a simple
Thanks for the recommendation @BilalAM . I do understand the value of consistent toStrings and the code you've linked to seems like a good "default" given no overrides.
I'll note, however, that this "manually creating output" has always been there in the
The javadoc for toString says it's:
I think between the two options below, the second one is more concise and easier to read:
OSHI's focus is on providing the specific values (including values in the millions and billions, or double-precision floating points) like the full memory values above, and allowing the user to format appropriately for their needs. The toStrings are mostly just for a nice visual output, rounding, trimming and formating with metric/binary, etc.. and are mostly a "nice to have" that may not need a standard format.
"Device Tree" based structures like USB devices connected by hubs, or hard drive/partition arrangements, simply don't display well on a default/standard toString.
Finally, I'm always hesitant to add dependencies, and really don't think we need one just for toStrings.
Hi @dbwiddis , now it is showing that you shared the repo with me. I surfed around and found the Sensor.java file in the repo. Is that the file I have to make changes to? I mean what's the process?
I found that this Sensor.java is an interface.
I kind of realise that I have to fork the project and make necessary changes.
Hi, @BooSandy1994. Here's a step by step.