use of com.intellij.openapi.util.MultiValuesMap in project intellij-community by JetBrains.
the class FacetModelBase method getFacetsByType.
@Override
@NotNull
public <F extends Facet> Collection<F> getFacetsByType(@NotNull Facet underlyingFacet, FacetTypeId<F> typeId) {
if (myChildFacets == null) {
MultiValuesMap<Pair<Facet, FacetTypeId>, Facet> children = new MultiValuesMap<>();
for (Facet facet : getAllFacets()) {
final Facet underlying = facet.getUnderlyingFacet();
if (underlying != null) {
children.put(Pair.create(underlying, facet.getTypeId()), facet);
}
}
Map<Pair<Facet, FacetTypeId>, Collection<Facet>> childFacets = new HashMap<>();
for (Pair<Facet, FacetTypeId> pair : children.keySet()) {
final Collection<Facet> facets = children.get(pair);
childFacets.put(pair, Collections.unmodifiableCollection(facets));
}
myChildFacets = childFacets;
}
//noinspection unchecked
final Collection<F> facets = (Collection<F>) myChildFacets.get(new Pair(underlyingFacet, typeId));
return facets != null ? facets : Collections.<F>emptyList();
}
Aggregations