1 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
3 package com.intellij.facet;
5 import org.jetbrains.annotations.NotNull;
6 import org.jetbrains.annotations.Nullable;
8 import java.util.Collection;
13 public interface FacetModel {
15 * Returns all facets in the module sorted in such a way that a facet will occur before any of its subfacets
16 * @return sorted array of facets
19 Facet<?>[] getSortedFacets();
22 * @return all facets in the module
25 Facet<?>[] getAllFacets();
28 * @param typeId type of facets
29 * @return all facets of the given type
32 <F extends Facet<?>> Collection<F> getFacetsByType(FacetTypeId<F> typeId);
35 * @param typeId type of facet
36 * @return first facet of the given type or {@code null} if the module doesn't contain facets of this type
39 <F extends Facet<?>> F getFacetByType(FacetTypeId<F> typeId);
42 * @param type type of facet
43 * @param name name of facet
44 * @return first facet of the given type with the given name or {@code null} if not found
47 <F extends Facet<?>> F findFacet(FacetTypeId<F> type, String name);
50 * @param underlyingFacet facet
51 * @param typeId type of subfacet
52 * @return first subfacet of the given facet
55 <F extends Facet<?>> F getFacetByType(@NotNull Facet<?> underlyingFacet, FacetTypeId<F> typeId);
58 * @param underlyingFacet facet
59 * @param typeId type of subfacet
60 * @return all subfacets of the given facet
63 <F extends Facet<?>> Collection<F> getFacetsByType(@NotNull Facet<?> underlyingFacet, FacetTypeId<F> typeId);
66 String getFacetName(@NotNull Facet<?> facet);