-
-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add toString methods to API interface implementations #942
Comments
I will work on the implementations for ComputerSystem and Baseboard. |
I will work on FirmWare,GlobalMemory and VirtualMemory implementations |
I will work on HWDiskStore and HWPartition |
Hello, @dbwiddis I'd like to contribute and work on the PowerSource implementation. Thanks for marking this as first-timers-only! |
My pleasure, @colinbobolin. After all, contributing here was my first commit and now look at me. :) This is actually a perfect Issue for that. Lots of small, accessible tasks that I don't have to do, and we all help each other! |
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. |
I see multiple people have already commented before me, but are there any implementations yet to be done? I would love to have a go. Thanks! |
I want to work on Sensors. I have never done these things before. It's a first for me and I might really need a helping hand. |
@dbwiddis Hello, I would like to work on NetworkIF and NetworkParams if still available. |
Looks like @johnaearley has clamed the two remaining Network tasks and @BooSandy1994 has Sensors. @GandalfTheJava can you please take the OSFileStore? Look at HWDiskStore as a sample! |
@dbwiddis I will get started on OSFileStore immediately! Thank you |
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.
|
Omg thank you very much ... I am on it. |
@dbwiddis I just added the toString method in the Abstract Sensor class. Do I need to delete the remaining 3 lines after tha Oshi.add("Sensors:" + sensors.toString()). I have merged the cpu temp, fan speed and cpu voltage in the toString method only. |
Yes, delete those lines. |
Also when I read the CONTRIBUTING section written at the start of this thread..... it is mentioned something like to run mvn test. |
You would have to install maven on your machine OR you can use the You can run the SystemInfoTest in your IDE to see if the output looks normal. |
Finally I was able push the changes with the chnagelogs and the code. |
Great job, @BooSandy1994 ! I'll just make a few formatting tweaks and merge it! |
Hi @dbwiddis , I have scanned the thread and I think your topics have all been covered but in case I missed something I would love the opportunity to help. If not, there's always next time. TY for posting. |
Hi, @rsersh , you are correct that all the topics have been claimed on this issue, but if you'd like to contribute there are many other things that can be done. Let me know if you'd like to pitch in elsewhere! |
Thank you, @dbwiddis. Yes, I would very much like to provide some assist where needed. |
Hi @dbwiddis it is my first time for looking for open source projects, and I really want to do this. |
Hi, @Praveen101997 ! Glad to know you want to help. I'm not sure there's anything right now that's not being worked on, but if you "watch" the project (click the link near the top of this page) you can see new issues when they pop up. |
Thanx for your reply |
Hi @dbwiddis ! It's my first time for Open Source contribution. I have read the whole thread and got that all the topics here have been claimed. If there are any such more open issues, please guide. Your comments on this issue have motivated me a lot to search for more to start with. Thank you. :) |
@johnaearley how's it going on the toStrings for the network info? If you don't have time to do them, there are a few other first-timers who would love to take a shot at it. |
@Praveen101997 and @shivangi14 check out #963 if either of you wants to try it. |
@dbwiddis Are there any tasks/implementations left to do? I would like to try to handle at least one. |
The two Network classes haven't been done... @johnaearley signed up for them but hasn't followed up. Can you pick one and if he pops up he can still do the other? |
@dbwiddis Yes. I'll try to do NetworkIf. |
Is there a particular way the string should be formatted for the NetworkIF class? |
Just grab the same formatting that is in the SystemInfoTest class, except don't indent the first line by a space (but indent the following lines as they are). So like this:
|
Hi @dbwiddis , is NetworkParams being worked on? I would like to try it. |
Go ahead and grab it, @shivangi14. |
Thanks @dbwiddis . I am on it. |
I'm pretty much done with the toString method. I'm just having problem testing it with JUnit (first time). I keep getting a NullPointerException for it. |
Let me know if I can help debug. :) It's less important to individually test the toStrings as they are all exercised in SystemInfoTest. |
@dbwiddis I successfully ran tests and it looks like everything is correct. The only question I have now is whether or not I need to add the /** {@inheritdoc} */ javadoc tag as well? |
@dbwiddis Thanks for the offer but I didn't get to see your reply before it was already too late lol. |
No, the inheritdoc is optional, added by a maven tool, and I’m actually removing them as I edit other code. |
In the SystemInfoTest class, should I remove everything from the printNetworkInterfaces method? |
Not everything... you need to call the toString with the header in front of it. |
This is what I have in the printNetworkInterfaces method: |
That looks good to me visually here... more importantly, do you like the output when you run |
Yeah. It looks identical to what you showed me earlier. |
Closing this issue as there's now a PR for the last submission. For those who want to contribute further, feel free to watch the project and check the Issues list for "Good first issue" tags. |
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
toString()
methods to all of the API classes, with the implementation in the associated Abstract class for interfaces. This has been done for AbstractOperatingSystem, AbstractDisplay, AbstractOSVersionInfoEx, AbstractSoundCard, AbstractUsbDevice, AbstractCentralProcessor, and the class OSProcessSimilar 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.
toString()
implementation.toString()
method in the Abstract class implementing the interface. See the above links for examples.toString()
method in the class.toString()
method you just created.The text was updated successfully, but these errors were encountered: