2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com
.intellij
.facet
;
19 import com
.intellij
.openapi
.Disposable
;
20 import com
.intellij
.openapi
.util
.Disposer
;
21 import com
.intellij
.openapi
.util
.UserDataHolderBase
;
22 import com
.intellij
.openapi
.util
.UserDataHolder
;
23 import com
.intellij
.openapi
.module
.Module
;
24 import org
.jetbrains
.annotations
.NotNull
;
27 * Represents a specific instance of facet
33 public class Facet
<C
extends FacetConfiguration
> extends UserDataHolderBase
implements UserDataHolder
, Disposable
{
34 public static final Facet
[] EMPTY_ARRAY
= new Facet
[0];
35 @NotNull private final FacetType myFacetType
;
36 @NotNull private final Module myModule
;
37 @NotNull private final C myConfiguration
;
38 private final Facet myUnderlyingFacet
;
39 private String myName
;
40 private boolean myImplicit
;
41 private boolean isDisposed
;
43 public Facet(@NotNull final FacetType facetType
, @NotNull final Module module
, @NotNull final String name
, @NotNull final C configuration
, Facet underlyingFacet
) {
45 myFacetType
= facetType
;
47 myConfiguration
= configuration
;
48 myUnderlyingFacet
= underlyingFacet
;
49 Disposer
.register(myModule
, this);
53 public final FacetType
getType() {
57 public final FacetTypeId
getTypeId() {
58 return myFacetType
.getId();
61 public final Facet
getUnderlyingFacet() {
62 return myUnderlyingFacet
;
66 public final C
getConfiguration() {
67 return myConfiguration
;
71 public final Module
getModule() {
76 public final boolean isImplicit() {
81 public final void setImplicit(final boolean implicit
) {
82 myImplicit
= implicit
;
86 * Called when the module containing this facet is initialized
88 public void initFacet() {
92 * Called when the module containing this facet is disposed
94 public void disposeFacet() {
97 public final void dispose() {
103 public final int hashCode() {
104 return super.hashCode();
107 @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
108 public final boolean equals(Object obj
) {
109 return super.equals(obj
);
113 public final String
getName() {
118 * Use {@link com.intellij.facet.ModifiableFacetModel#rename} to rename facets
120 final void setName(@NotNull final String name
) {