001/* 002 * Copyright 2010-2013 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 017package org.jetbrains.jet.lang.resolve.java.kt; 018 019import com.intellij.psi.PsiAnnotation; 020import org.jetbrains.annotations.Nullable; 021import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; 022 023public abstract class PsiAnnotationWithFlags extends PsiAnnotationWrapper { 024 private int flags; 025 026 protected PsiAnnotationWithFlags(@Nullable PsiAnnotation psiAnnotation) { 027 super(psiAnnotation); 028 } 029 030 @Override 031 protected void initialize() { 032 flags = getIntAttribute(JvmStdlibNames.JET_FLAGS_FIELD, JvmStdlibNames.FLAGS_DEFAULT_VALUE); 033 } 034 035 public final int flags() { 036 checkInitialized(); 037 return flags; 038 } 039 040 public final boolean hasPropertyFlag() { 041 return (flags() & JvmStdlibNames.FLAG_PROPERTY_BIT) != 0; 042 } 043 044 public final boolean hasForceFinalFlag() { 045 return (flags() & JvmStdlibNames.FLAG_FORCE_FINAL_BIT) != 0; 046 } 047 048 public final boolean hasForceOpenFlag() { 049 return (flags() & JvmStdlibNames.FLAG_FORCE_OPEN_BIT) != 0; 050 } 051 052 public final boolean hasInternalFlag() { 053 return (flags() & JvmStdlibNames.FLAG_INTERNAL_BIT) != 0; 054 } 055 056 public final boolean hasProtectedFlag() { 057 return (flags() & JvmStdlibNames.FLAG_PROTECTED_BIT) != 0; 058 } 059 060 public final boolean hasPrivateFlag() { 061 return (flags() & JvmStdlibNames.FLAG_PRIVATE_BIT) != 0; 062 } 063}