[JAVA-3380] Default values for Document#getLong and Document#getDouble Created: 08/Aug/19 Updated: 27/Oct/23 Resolved: 09/Aug/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Shea Cartwright | Assignee: | Jeffrey Yemin |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
N/A |
||
| Description |
|
Would it be possible to add default values to Document#getLong and Document#getDouble, you can already do it through Document#getEmbedded but that seems impractical. Pretty much all the getX's have an option for a default value so I don't know if there's a reason you haven't done it for double and long. |
| Comments |
| Comment by Jeffrey Yemin [ 09/Aug/19 ] | |||||||
|
I suspect the getX's preceded this method. | |||||||
| Comment by Shea Cartwright [ 09/Aug/19 ] | |||||||
|
I see, didn't know this was a thing thank you. Just out of interest why do you have the getX's if you can just do this for every type? | |||||||
| Comment by Jeffrey Yemin [ 09/Aug/19 ] | |||||||
|
Sorry, I totally messed up that example. Try this:
It will print
| |||||||
| Comment by Shea Cartwright [ 09/Aug/19 ] | |||||||
|
Wouldn't you need to provide it with a key in some way? | |||||||
| Comment by Jeffrey Yemin [ 08/Aug/19 ] | |||||||
|
You can also use `<T> T Document#get(java.lang.Object, T)`, as in:
|