Java tutorial
//package com.java2s; import com.mongodb.ReadPreference; import java.util.HashMap; import java.util.Map; public class Main { private static final Map<String, ReadPreference> values = new HashMap<String, ReadPreference>(2); public static ReadPreference valueOf(String name) { return values.get(name.toLowerCase()); } }