[JAVA-175] Add WriterConcern.valueOf WAS: Make WriteConcern a Enum Created: 06/Oct/10 Updated: 29/Oct/10 Resolved: 19/Oct/10 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 2.3 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Mathias Bogaert | Assignee: | Scott Hernandez (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Would be cool if the WriteConcern class was a Java5 Enum. That way, one could pass a string (.valueOf(String)) coming from a config file to it. Shouldn't affect existing code bases much. |
| Comments |
| Comment by auto [ 21/Oct/10 ] |
|
Author: {'login': 'scotthernandez', 'name': 'Scott Hernandez', 'email': 'scotthernandez@hotmail.com'}Message: add valueOf for issue |
| Comment by Scott Hernandez (Inactive) [ 19/Oct/10 ] |
|
Patch, http://github.com/scotthernandez/mongo-java-driver/commit/1557f5723d1b5fff05174177d2bb110e881404f3 |
| Comment by Eliot Horowitz (Inactive) [ 10/Oct/10 ] |
|
As scott said - this recently went the other way. Though adding a way to easily go from String to WriteConcern makes sense |
| Comment by Scott Hernandez (Inactive) [ 06/Oct/10 ] |
|
It used to be an enum, but now since it encompasses many values this makes less sense. We aren't going to name every combination and that is the problem. We could make it an enum (since an enum is only a class) and name a few predefined options like we have done (currently using statics). That unfortunately feels a bit hackish, and could be confusing to some people as it means you would have to use a custom enum constructor (or special static method) to create non-predefined instances of the enum. Where do you expect to be able to define something in a config file that would get set in code? Either way you need some kind of converter (and setter) so why not just do it yourself? You can even use the static fields on WriteConcern (via reflection) very easily (or we could write a helper method to do that). |