001 /*
002 * Copyright 2010-2015 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.kotlin.load.java.structure.impl;
018
019 import com.intellij.psi.PsiClass;
020 import com.intellij.psi.PsiTypeParameter;
021 import org.jetbrains.annotations.NotNull;
022 import org.jetbrains.annotations.Nullable;
023 import org.jetbrains.kotlin.load.java.structure.JavaAnnotation;
024 import org.jetbrains.kotlin.load.java.structure.JavaClassifier;
025 import org.jetbrains.kotlin.name.FqName;
026
027 import java.util.Collection;
028
029 public abstract class JavaClassifierImpl<Psi extends PsiClass> extends JavaElementImpl<Psi> implements JavaClassifier, JavaAnnotationOwnerImpl {
030 protected JavaClassifierImpl(@NotNull Psi psiClass) {
031 super(psiClass);
032 }
033
034 @NotNull
035 /* package */ static JavaClassifierImpl<?> create(@NotNull PsiClass psiClass) {
036 if (psiClass instanceof PsiTypeParameter) {
037 return new JavaTypeParameterImpl((PsiTypeParameter) psiClass);
038 }
039 else {
040 return new JavaClassImpl(psiClass);
041 }
042 }
043
044 @NotNull
045 @Override
046 public Collection<JavaAnnotation> getAnnotations() {
047 return JavaElementUtil.getAnnotations(this);
048 }
049
050 @Nullable
051 @Override
052 public JavaAnnotation findAnnotation(@NotNull FqName fqName) {
053 return JavaElementUtil.findAnnotation(this, fqName);
054 }
055
056 @Override
057 public boolean isDeprecatedInJavaDoc() {
058 return getPsi().isDeprecated();
059 }
060 }