Add name parameter to @SharedPref#1918
Add name parameter to @SharedPref#1918WonderCsabo merged 2 commits intoandroidannotations:developfrom dodgex:1675_add_name_parameter_to_shared_pref
Conversation
|
@dodgex please change the PR title, it is pretty ugly how it was generated from the branch name. |
| 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.
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); |
|
@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.