@Test public void get_null_is_accepted() { FacetRegistry registry = new FacetRegistry(new ArrayList<>()); Assertions.assertThat((Object)registry.getFacet(null)).isNull(); }
<T> T getFacet(@Nullable Class<T> facet) throws IllegalStateException { T plugin = null; if (facet != null) { List<T> plugins = getFacets(facet); if (plugins.size() > 1) { throw new IllegalStateException(String.format("One implementation was expected for the %s facet, but found: %s", facet.getSimpleName(), plugins.toString())); } else if (plugins.size() == 1) { plugin = plugins.get(0); } } return plugin; }
FacetRegistry { <T> T getFacet(@Nullable Class<T> facet) throws IllegalStateException { T plugin = null; if (facet != null) { List<T> plugins = getFacets(facet); if (plugins.size() > 1) { throw new IllegalStateException(String.format("One implementation was expected for the %s facet, but found: %s", facet.getSimpleName(), plugins.toString())); } else if (plugins.size() == 1) { plugin = plugins.get(0); } } return plugin; } }
FacetRegistry { <T> T getFacet(@Nullable Class<T> facet) throws IllegalStateException { T plugin = null; if (facet != null) { List<T> plugins = getFacets(facet); if (plugins.size() > 1) { throw new IllegalStateException(String.format("One implementation was expected for the %s facet, but found: %s", facet.getSimpleName(), plugins.toString())); } else if (plugins.size() == 1) { plugin = plugins.get(0); } } return plugin; } FacetRegistry(final Collection<Plugin> plugins); }
FacetRegistry { <T> T getFacet(@Nullable Class<T> facet) throws IllegalStateException { T plugin = null; if (facet != null) { List<T> plugins = getFacets(facet); if (plugins.size() > 1) { throw new IllegalStateException(String.format("One implementation was expected for the %s facet, but found: %s", facet.getSimpleName(), plugins.toString())); } else if (plugins.size() == 1) { plugin = plugins.get(0); } } return plugin; } FacetRegistry(final Collection<Plugin> plugins);  }
FacetRegistry { <T> T getFacet(@Nullable Class<T> facet) throws IllegalStateException { T plugin = null; if (facet != null) { List<T> plugins = getFacets(facet); if (plugins.size() > 1) { throw new IllegalStateException(String.format("One implementation was expected for the %s facet, but found: %s", facet.getSimpleName(), plugins.toString())); } else if (plugins.size() == 1) { plugin = plugins.get(0); } } return plugin; } FacetRegistry(final Collection<Plugin> plugins);   }