Facet (Module module, FacetType<?, ?> type, final @Nullable Facet underlying) { final Collection<? extends Facet> facets = getFacetsByType(module, type.getId()); String facetName = type.getDefaultFacetName(); int i = 2; while (facetExists(facetName, facets)) { facetName = type.getDefaultFacetName() + i; i++; } final Facet facet = FacetManager.getInstance(module).createFacet(type, facetName, underlying); myCreatedFacets.add(facet); addFacetInfo(facet); getOrCreateModifiableModel(module).addFacet(facet); return facet; }