-
-
Notifications
You must be signed in to change notification settings - Fork 889
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 disk and partition API #943
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a note, let's keep the indentation formatting and newlines in the "test" class and have the toString return a String without leading or trailing whitespace/newline/characters.
public String toString() { | ||
boolean readwrite = getReads() > 0 || getWrites() > 0; | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(' ').append(getName()).append(": "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave the space on the SystemInfoTest class and start this one with the name?
sb.append(" (").append(readwrite ? FormatUtil.formatBytes(getReadBytes()) : "?").append("), "); | ||
sb.append("writes: ").append(readwrite ? getWrites() : "?"); | ||
sb.append(" (").append(readwrite ? FormatUtil.formatBytes(getWriteBytes()) : "?").append("), "); | ||
sb.append("xfer: ").append(readwrite ? getTransferTime() : "?").append("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add the trailing new-line here.
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(" |-- ").append(getIdentification()).append(": "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to earlier comment let's keep the indentation (" |-- "
) in the SystemInfoTest
output and start the toString with text.
sb.append("(").append(getType()).append(") "); | ||
sb.append("Maj:Min=").append(getMajor()).append(":").append(getMinor()).append(", "); | ||
sb.append("size: ").append(FormatUtil.formatBytesDecimal(getSize())); | ||
sb.append(getMountPoint().isEmpty() ? "" : " @ " + getMountPoint()).append("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And similar to earlier, don't include the newline in the toString. If needed for the output, add in the other class (but it may not be needed there).
Codecov Report
@@ Coverage Diff @@
## master #943 +/- ##
============================================
+ Coverage 74.85% 75.14% +0.28%
Complexity 2 2
============================================
Files 22 22
Lines 1038 1058 +20
Branches 130 137 +7
============================================
+ Hits 777 795 +18
Misses 204 204
- Partials 57 59 +2
Continue to review full report at Codecov.
|
Removed leading or trailing whitespace/newline/characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Looks great! I tweaked some formatting, removed an unneeded null check, and added a test and changelog entry. Will merge as soon as the CI tests finish! Thanks for contributing to open source! |
Thanks for the opportunity! |
HWDiskStore & HWPartition toString Methods for #942