Skip to content

Commit a65a4de

Browse files
committed
JAVA-744: Added MongoClientOptions.builder() static convenience method.
1 parent 5391df1 commit a65a4de

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/com/mongodb/MongoClientOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ public MongoClientOptions build() {
310310
}
311311
}
312312

313+
/**
314+
* Create a new Builder instance. This is a convenience method, equivalent to {@code new MongoClientOptions.Builder()}.
315+
*
316+
* @return a new instance of a Builder
317+
*/
318+
public static Builder builder() {
319+
return new Builder();
320+
}
321+
313322
/**
314323
* Gets the description for this MongoClient, which is used in various places like logging and JMX.
315324
* <p/>
@@ -502,6 +511,8 @@ public boolean isAlwaysUseMBeans() {
502511
return alwaysUseMBeans;
503512
}
504513

514+
515+
505516
private MongoClientOptions(final Builder builder) {
506517
description = builder.description;
507518
connectionsPerHost = builder.connectionsPerHost;

src/test/com/mongodb/MongoClientOptionsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,9 @@ public DBDecoder create() {
155155
Assert.assertEquals(encoderFactory, options.getDbEncoderFactory());
156156
Assert.assertEquals(decoderFactory, options.getDbDecoderFactory());
157157
}
158+
159+
@Test
160+
public void testStaticBuilderCreate() {
161+
Assert.assertNotNull(MongoClientOptions.builder());
162+
}
158163
}

0 commit comments

Comments
 (0)