Reading the string out of the vertx config file via getOptionalStringConfig is fine, the issue is the conversion from String -> ReadPreference. There is a method in the Mongo driver for this at https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ReadPreference.java#L231 so you can re-use that rather than implementing your own switch.