MetaMapOptions { @SuppressWarnings("ReturnOfNull") public static Option strToOpt(final String optStr) { final String[] parts = SPACE.split(optStr, 2); final String name = parts[0]; final String param = 1 < parts.length ? parts[1] : null; final Option opt = OPTS.get(name); return opt == null ? null : opt.newInstance(param); } private  MetaMapOptions(); @SuppressWarnings("ReturnOfNull") static Option strToOpt(final String optStr); @SuppressWarnings("PublicStaticCollectionField")
    static final ImmutableCollection<Option> DEFAULT_MM_OPTIONS; }
@Test public void test() throws Exception { final Option o1 = MetaMapOptions.strToOpt("foobar"); assertNull(o1); final Option o2 = MetaMapOptions.strToOpt("word_sense_disambiguation"); assertNotNull(o2); assertEquals(o2.getClass(), WordSenseDisambiguation.class); assertEquals(o2.name(), "word_sense_disambiguation"); assertNull(o2.param()); assertEquals(o2.toMmOptStr(), "--word_sense_disambiguation"); final Option o3 = MetaMapOptions.strToOpt("composite_phrases"); assertNull(o3); final Option o4 = MetaMapOptions.strToOpt("composite_phrases X"); assertNull(o4); final Option o5 = MetaMapOptions.strToOpt("composite_phrases 20"); assertNull(o5); final Option o6 = MetaMapOptions.strToOpt("composite_phrases 4"); assertNotNull(o6); assertEquals(o6.getClass(), CompositePhrases.class); assertEquals(o6.toMmOptStr(), "--composite_phrases 4"); }