-
Notifications
You must be signed in to change notification settings - Fork 27
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
Improve EnumInteger-System #41
Conversation
Moved EnumInteger to new package conv (conversion) as first step to refactoring the EnumInteger-System Moved the appropiate Test Updated imports in all accessors
Moved EnumIntegerSet to package conv Moved the appropiate Test Updated imports in all accessors
Generified EnumInteger to not necessarily represent a bitmask, but an intValue that represents the Enum Modified depended classes to reflect this change Modified Tests to reflect this change Added overloaded version of EnumInteger#enumFromInt that accepts an enum-type instead of an array of possible values
…o an EnumIntegerSet
Renamed EnumIntegerSet to MaskValueSet Updated depended classes Renamed appropriate Test
Changed MaskValueSet to only accept MaskValueEnums (and therefore match it's contract)
Changed MaskValueSet to an interface and added class MaskValueSetImpl as implementor
…hod and renamed #fromInt Renamed MaskValueSet#enumSetFromInt to #getSetFromInt Renamed #fromInt in MaskValueEnums to #getSetFromInt Added #getSetFromInt to MaskValueEnums where it was missing Updated depended classes Added overloaded version of MaskValueSet#getSetFromInt that accepts an enum-type instead of an array of possible values Added delegate-method (getSetFromInt) to MaskValueEnum
Added #fromInt to EnumIntegers where it was missing
2fcd4f6
to
e01b376
Compare
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.
First of all. thank you for this pull request. It adds typesafety and reduces wrong use of the system.
A thing which should be discussed is the naming of some objects. I don't like the new package name. I assume it stands for conversion, but conversion would only contain classes for the conversion action, not the conversion results. I suggest the package name wrapper
, because the int value is wrapped in a type safe manner and in the end these objects still represent the value, therefore wrap it.
The comments for MountOption.java
hold basically for all classes implementing the MaskValueEnum
.
Splitting the MaskValueEnum
into interface and implementation is overengineering for this library, but acceptable from my point of view.
src/main/java/dev/dokan/dokan_java/constants/dokany/MountOption.java
Outdated
Show resolved
Hide resolved
src/main/java/dev/dokan/dokan_java/constants/dokany/MountOption.java
Outdated
Show resolved
Hide resolved
Same goes for the cases where my comments are missing.
For documentation purposes: The idea was to stand in line with the JDK-Collections, where you usually also deal with a lot of interfaces. It also makes swapping out the backend easier in case it's needed. |
Because the other PR is currently only in a draft state, we can act independetly of it from my point of view. But even if we consider it, why is it a problem to add both in the same package? The MaskValueSet and others are also convenience classes for easier use. And finally, nowadays package names can be easily changed due to the great IDE support. |
Renamed getSetFromInt to maskValueSet (and renamed parameter value to mask) See: dokan-dev#41 (comment) Renamed getMaskValue to getMaskingValue See: dokan-dev#41 (comment)
…dokan-java into improved-enumintegers
Putting too many classes into a package can lead to even more confusion than misleading package names. Also the EnumInteger-API is pretty much decoupled from the other wrapper classes and used over the whole project. That's why I wanted to keep it separate. |
Renamed getMaskingValue to maskingValue in MaskValueEnum to match "intValue" in EnumInteger
Good point. How about renaming the package to |
@infeo and I agreed on "masking" as package name. |
…lueSet Added IntegerConvertible as base interface for EnumInteger and MaskValueSet. IntergerConvertible defines the intValue() method and marks classes that can be converted into ints and vice-versa. Changed EnumInteger to explicitly wrap Enums as special case of IntegerConvertible Changed MaskValueSet to extend IntegerConvertible and renamed method toInt to intValue in accordance to IntegerConvertible Changed method calls to refelct this change
Added new package conv (conversion)
Added convenience methods
Added missing static methods
Added IntegerConvertible as base interface of EnumInteger
Added MaskValue as special case of EnumInteger that is used to express masks
Renamed EnumIntegerSet to MaskValueSet and changed it to only accept MaskValues
Made EnumIntegerSet an interface and added EnumIntegerSetImpl as implementation
Renamed enumSetFromInt to
getSetFromIntmaskValueSet