-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add name parameter to @SharedPref #1918
Add name parameter to @SharedPref #1918
Conversation
|
@dodgex please change the PR title, it is pretty ugly how it was generated from the branch name. |
WonderCsabo
left a comment
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.
LGTM!
| boolean hasCustomName = !name.trim().isEmpty(); | ||
| EnumSet<SharedPref.Scope> allowedScopes = EnumSet.of(SharedPref.Scope.ACTIVITY, SharedPref.Scope.UNIQUE); | ||
| if (hasCustomName && !allowedScopes.contains(scope)) { | ||
| validation.addWarning("SharedPref#name() is only supported for Scope.ACTIVITY and Scope.UNIQUE."); |
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.
I would add an error() here. Better failing at compile time than spending hours debugging this at runtime.
| SharedPref.Scope scope = sharedPrefAnnotation.value(); | ||
| String name = sharedPrefAnnotation.name(); | ||
| boolean hasCustomName = !name.trim().isEmpty(); | ||
| EnumSet<SharedPref.Scope> allowedScopes = EnumSet.of(SharedPref.Scope.ACTIVITY, SharedPref.Scope.UNIQUE); |
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.
Nice!
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.
:)
|
@WonderCsabo I changed from warning to error and now i get a test failure due to a class that has nothing to do with the test?!
any idea? :( |
|
@dodgex about the test failure: i am just guessing, but maybe |
|
Don't know... i copied that from |
This PR implements the feature request of #1675.
With this PR it is possible to provide a custom name for the preference file of a
@SharedPrefinterface.