@Test public void getConverter() { XSettings xsettings1 = mock(XSettings.class); XSettings xsettings2 = mock(XSettings.class); when(facetValueConverter1.handles(xsettings1)).thenReturn(true); when(facetValueConverter1.handles(xsettings2)).thenReturn(false); when(facetValueConverter2.handles(xsettings1)).thenReturn(false); when(facetValueConverter2.handles(xsettings2)).thenReturn(true); assertTrue(facetValueConverter1 == manager.getConverter(xsettings1)); assertFalse(facetValueConverter1 == manager.getConverter(xsettings2)); assertTrue(facetValueConverter2 == manager.getConverter(xsettings2)); assertFalse(facetValueConverter2 == manager.getConverter(xsettings1)); }
public FacetValueConverter getConverter(XSettings xsettings) { Preconditions.checkNotNull(xsettings); for (FacetValueConverter converter :converters) { if (converter.handles(xsettings)) { return converter; } } throw new IllegalArgumentException("no FacetValueConverter can be found for " + xsettings); }
FacetValueConverterManager { public FacetValueConverter getConverter(XSettings xsettings) { Preconditions.checkNotNull(xsettings); for (FacetValueConverter converter :converters) { if (converter.handles(xsettings)) { return converter; } } throw new IllegalArgumentException("no FacetValueConverter can be found for " + xsettings); } }
FacetValueConverterManager { public FacetValueConverter getConverter(XSettings xsettings) { Preconditions.checkNotNull(xsettings); for (FacetValueConverter converter :converters) { if (converter.handles(xsettings)) { return converter; } } throw new IllegalArgumentException("no FacetValueConverter can be found for " + xsettings); }  }
FacetValueConverterManager { public FacetValueConverter getConverter(XSettings xsettings) { Preconditions.checkNotNull(xsettings); for (FacetValueConverter converter :converters) { if (converter.handles(xsettings)) { return converter; } } throw new IllegalArgumentException("no FacetValueConverter can be found for " + xsettings); }  FacetValueConverter getConverter(XSettings xsettings); void setConverters(List<? extends FacetValueConverter> converters); }
FacetValueConverterManager { public FacetValueConverter getConverter(XSettings xsettings) { Preconditions.checkNotNull(xsettings); for (FacetValueConverter converter :converters) { if (converter.handles(xsettings)) { return converter; } } throw new IllegalArgumentException("no FacetValueConverter can be found for " + xsettings); }  FacetValueConverter getConverter(XSettings xsettings); void setConverters(List<? extends FacetValueConverter> converters);  }