[JAVA-2381] Implement builder for MongoClientURI (and maybe ConnectionString) Created: 11/Nov/16  Updated: 28/Dec/16  Resolved: 28/Dec/16

Status: Closed
Project: Java Driver
Component/s: Configuration
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: gross Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible

 Description   

Currently MongoClientURI can be created either from String or String + MongoClientOptions.Builder and can't be created from existing MongoClientURI with some alterations.

I propose adding a builder (public static inner class in MongoClientURI would be OK, I think) with convenience static methods like MongoClientURI.builder() and MongoClientURI.builder(MongoClientURI from).

Builder itself would have convenient methods like hosts(String...), hosts(List<String>), database(String), collection(String), username(String), password(char[]) and a number of methods for standard options, present in ConnectionString/MongoClientURI.

If this proposal is acceptable, I'll publish prototype on github.



 Comments   
Comment by Jeffrey Yemin [ 28/Dec/16 ]

Hi Konstantin,

As we haven't heard back from you with a response to our questions, I'm closing this issue. Feel free to respond when you can and we can re-open if necessary.

Comment by Ross Lawley [ 11/Nov/16 ]

Hi grossws,

Thanks for the ticket. I'm unclear as to the purpose of this suggestion. Given you already have a way to override MongoClientURI settings with the MongoClientOptions.Builder why complicate it by adding a third way to set options?

Or are you after a way to programatically construct a ConnectionString?

Ross

Generated at Thu Feb 08 08:57:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.