-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement Setting class #102
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #102 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 61 78 +17
Lines 1627 2058 +431
==========================================
+ Hits 1627 2058 +431 ☔ View full report in Codecov by Sentry. |
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.
Is syntax for callables ok?
Did I properly implement the IntegerParser?
Yes, but you can also object orient this, including subclassing a simpler Setting
into ReadWritableSetting
, and creating a SettingsParser#parse
passed around as objects.
Better idea than the class method for the Java static intSetting() equivalent?
Should be a IntegerSetting()
constructor that does all validation and parsing within.
Hmm. On Java SDK we only use
Thought of this: in Java
I like this idea. One other thing to note: the original port tried to faithfully model the exact Java classes, but I think making the |
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.
This looks good to me!
I still don't see what the advantage is of making a parser a callable instead of inheriting them all from an abstract class Settings > class Parser
that implements a parse
method?
Still in progress, need to handle TimeValue, ByteSizeValue (similar to the existing), Boolean (simpler), and String (which will involve validator) and then handle the transport actions to communicate them.
I haven't fully decided not to switch yet, but am still leaning toward keeping it as is for now, as it matches the Java-side implementation so porting from Java SDK code is likely more straightforward. I think we can always switch later; isn't it essentially just replacing It's a similar question with the validator and default value that I haven't fully decided on either and would probably want to implement similarly for all of them. Validator is much more obviously something we'd do a similar parent class for, but right now is only implemented for Strings. Default value is interesting as it takes a TLDR: leaving as is for now but thinking it's an easy switch later. This whole setting system is more complex than you'd think and I'm handling it bite by bite (byte by byte?). |
Yes. I don't feel strongly about it. I like OO over function calls. Similarly you wouldn't build a LOL the XKCD is a great reminder that programming is just copy paste from SO (or another Java codebase) |
Can't do that in an Apache project ;) I will admit that the |
Related to the XKCD, this is still one of the favorite pair of comments I've left in code: https://github.com/oshi/oshi/blob/35d3bd754fafdb82c72bcb0976809d8700b60aff/oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStore.java#L122-L132 |
I couldn't get past the fact that |
Blame Microsoft. String PHYSICALDRIVE_PREFIX = "\\\\.\\PHYSICALDRIVE"; |
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Amazing how one class can turn into 32 files and 1402 lines of code... Ready for review (you might just want to look at the last 2 commits). |
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Description
Implements the Setting class.
Context:
Settings
class already committed is a key-value map with mostly string values (or nested maps)Setting
class is an individual setting which will be stored in thatSettings
map with a current (string) valueParser
functional interface (callable in Python) to a typed valueIssues Resolved
Part of #84
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.