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.
2 package com.intellij.psi;
4 import com.intellij.lang.jvm.JvmModifier;
5 import org.jetbrains.annotations.NonNls;
6 import org.jetbrains.annotations.NotNull;
7 import org.jetbrains.annotations.Nullable;
9 import static com.intellij.psi.PsiJvmConversionHelper.hasListModifier;
12 * Represents a PSI element which has a list of modifiers (public/private/protected/etc.)
15 public interface PsiModifierListOwner extends PsiElement {
18 * Returns the list of modifiers for the element.
20 * @return the list of modifiers, or null if the element (for example, an anonymous
21 * inner class) does not have the list of modifiers.
24 PsiModifierList getModifierList();
27 * Checks if the element has the specified modifier. Possible modifiers are defined
28 * as constants in the {@link PsiModifier} class.
30 * @param name the name of the modifier to check.
31 * @return true if the element has the modifier, false otherwise
33 boolean hasModifierProperty(@PsiModifier.ModifierConstant @NonNls @NotNull String name);
36 default PsiAnnotation[] getAnnotations() {
37 return PsiJvmConversionHelper.getListAnnotations(this);
41 default PsiAnnotation getAnnotation(@NotNull String fqn) {
42 return PsiJvmConversionHelper.getListAnnotation(this, fqn);
45 default boolean hasAnnotation(@NotNull String fqn) {
46 return PsiJvmConversionHelper.hasListAnnotation(this, fqn);
49 default boolean hasModifier(@NotNull JvmModifier modifier) {
50 return hasListModifier(this, modifier);