@Test public void get_alternate_translator_by_name() { Translator t1 = mockTranslator("fred", Integer.class); Translator t2 = mockTranslator(); Map<Class, Translator> configuration = newConfiguration(Integer.class, t1); Map<String, Translator> alternates = CollectionFactory.newMap(); alternates.put("barney", t2); replay(); TranslatorSource source = new TranslatorSourceImpl(configuration, alternates); assertSame(source.get("barney"), t2); verify(); }
public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } TranslatorSourceImpl(Map<Class, Translator> configuration);  TranslatorSourceImpl(Map<Class, Translator> configuration, Map<String, Translator> alternates); }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } TranslatorSourceImpl(Map<Class, Translator> configuration);  TranslatorSourceImpl(Map<Class, Translator> configuration, Map<String, Translator> alternates); Translator get(String name); Translator getByType(Class valueType); Translator findByType(Class valueType); void run(); }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } TranslatorSourceImpl(Map<Class, Translator> configuration);  TranslatorSourceImpl(Map<Class, Translator> configuration, Map<String, Translator> alternates); Translator get(String name); Translator getByType(Class valueType); Translator findByType(Class valueType); void run();  }