001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.commons.reflect;
018
019/**
020 * Enumeration of possible modifiers and attributes that can be present on classes, methods, fields, and constructors.
021 *
022 * <p>
023 * This enum provides a comprehensive set of flags for identifying Java language modifiers (public, private, static, etc.)
024 * and other attributes (synthetic, deprecated, etc.) that can be present on program elements. Each modifier has both
025 * a positive flag (e.g., <c>PUBLIC</c>) and a negated flag (e.g., <c>NOT_PUBLIC</c>) for convenient filtering.
026 *
027 * <h5 class='section'>Features:</h5>
028 * <ul class='spaced-list'>
029 *    <li>Java modifiers - all standard Java modifiers (public, private, protected, static, final, etc.)
030 *    <li>Negated flags - each modifier has a corresponding NOT_* flag for filtering
031 *    <li>Non-modifier attributes - flags for synthetic, deprecated, bridge methods, etc.
032 *    <li>Type attributes - flags for identifying classes, interfaces, enums, records, annotations
033 * </ul>
034 *
035 * <h5 class='section'>Use Cases:</h5>
036 * <ul class='spaced-list'>
037 *    <li>Filtering classes, methods, fields by modifiers
038 *    <li>Identifying special attributes (synthetic, deprecated, bridge methods)
039 *    <li>Type checking (enum, record, annotation, interface)
040 *    <li>Building frameworks that need to analyze program element characteristics
041 * </ul>
042 *
043 * <h5 class='section'>Usage:</h5>
044 * <p class='bjava'>
045 *    <jc>// Check if a class is public</jc>
046 *    ClassInfo <jv>ci</jv> = ClassInfo.<jsm>of</jsm>(MyClass.<jk>class</jk>);
047 *    <jk>boolean</jk> <jv>isPublic</jv> = <jv>ci</jv>.hasFlag(ElementFlag.PUBLIC);
048 *
049 *    <jc>// Filter methods by modifier</jc>
050 *    List&lt;MethodInfo&gt; <jv>staticMethods</jv> = <jv>ci</jv>.getMethods()
051 *       .stream()
052 *       .filter(<jv>m</jv> -&gt; <jv>m</jv>.hasFlag(ElementFlag.STATIC))
053 *       .toList();
054 *
055 *    <jc>// Check for deprecated methods</jc>
056 *    <jk>boolean</jk> <jv>isDeprecated</jv> = <jv>method</jv>.hasFlag(ElementFlag.DEPRECATED);
057 * </p>
058 *
059 * <h5 class='section'>Modifier Flags:</h5>
060 * <p>
061 * Standard Java modifiers: <c>PUBLIC</c>, <c>PRIVATE</c>, <c>PROTECTED</c>, <c>STATIC</c>, <c>FINAL</c>,
062 * <c>SYNCHRONIZED</c>, <c>VOLATILE</c>, <c>TRANSIENT</c>, <c>NATIVE</c>, <c>ABSTRACT</c>.
063 * Each has a corresponding <c>NOT_*</c> flag.
064 *
065 * <h5 class='section'>Attribute Flags:</h5>
066 * <p>
067 * Non-modifier attributes: <c>ANNOTATION</c>, <c>ANONYMOUS</c>, <c>ARRAY</c>, <c>BRIDGE</c>, <c>CLASS</c>,
068 * <c>CONSTRUCTOR</c>, <c>DEFAULT</c>, <c>DEPRECATED</c>, <c>ENUM</c>, <c>ENUM_CONSTANT</c>, <c>HAS_PARAMS</c>,
069 * <c>LOCAL</c>, <c>MEMBER</c>, <c>NON_STATIC_MEMBER</c>, <c>PRIMITIVE</c>, <c>RECORD</c>, <c>SEALED</c>,
070 * <c>SYNTHETIC</c>, <c>VARARGS</c>.
071 *
072 * <h5 class='section'>See Also:</h5><ul>
073 *    <li class='jc'>{@link ElementInfo} - Base class that uses these flags
074 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauCommonsReflection">Reflection Package</a>
075 * </ul>
076 */
077public enum ElementFlag {
078
079   // Java modifiers from java.lang.reflect.Modifier
080
081   /** PUBLIC modifier */
082   PUBLIC,
083
084   /** NOT_PUBLIC (negated) */
085   NOT_PUBLIC,
086
087   /** PRIVATE modifier */
088   PRIVATE,
089
090   /** NOT_PRIVATE (negated) */
091   NOT_PRIVATE,
092
093   /** PROTECTED modifier */
094   PROTECTED,
095
096   /** NOT_PROTECTED (negated) */
097   NOT_PROTECTED,
098
099   /** STATIC modifier */
100   STATIC,
101
102   /** NOT_STATIC (negated) */
103   NOT_STATIC,
104
105   /** FINAL modifier */
106   FINAL,
107
108   /** NOT_FINAL (negated) */
109   NOT_FINAL,
110
111   /** SYNCHRONIZED modifier */
112   SYNCHRONIZED,
113
114   /** NOT_SYNCHRONIZED (negated) */
115   NOT_SYNCHRONIZED,
116
117   /** VOLATILE modifier */
118   VOLATILE,
119
120   /** NOT_VOLATILE (negated) */
121   NOT_VOLATILE,
122
123   /** TRANSIENT modifier */
124   TRANSIENT,
125
126   /** NOT_TRANSIENT (negated) */
127   NOT_TRANSIENT,
128
129   /** NATIVE modifier */
130   NATIVE,
131
132   /** NOT_NATIVE (negated) */
133   NOT_NATIVE,
134
135   /** INTERFACE modifier */
136   INTERFACE,
137
138   /** ABSTRACT modifier */
139   ABSTRACT,
140
141   /** NOT_ABSTRACT (negated) */
142   NOT_ABSTRACT,
143
144   // Non-modifier attributes
145
146   /** ANNOTATION (is an annotation type) */
147   ANNOTATION,
148
149   /** NOT_ANNOTATION (not an annotation type) */
150   NOT_ANNOTATION,
151
152   /** ANONYMOUS (is an anonymous class) */
153   ANONYMOUS,
154
155   /** NOT_ANONYMOUS (not an anonymous class) */
156   NOT_ANONYMOUS,
157
158   /** ARRAY (is an array type) */
159   ARRAY,
160
161   /** NOT_ARRAY (not an array type) */
162   NOT_ARRAY,
163
164   /** BRIDGE (is a bridge method) */
165   BRIDGE,
166
167   /** NOT_BRIDGE (not a bridge method) */
168   NOT_BRIDGE,
169
170   /** CLASS (is a class, not an interface) */
171   CLASS,
172
173   /** CONSTRUCTOR (is a constructor) */
174   CONSTRUCTOR,
175
176   /** NOT_CONSTRUCTOR (not a constructor) */
177   NOT_CONSTRUCTOR,
178
179   /** DEFAULT (is a default interface method) */
180   DEFAULT,
181
182   /** NOT_DEFAULT (not a default interface method) */
183   NOT_DEFAULT,
184
185   /** DEPRECATED (has @Deprecated annotation) */
186   DEPRECATED,
187
188   /** NOT_DEPRECATED (no @Deprecated annotation) */
189   NOT_DEPRECATED,
190
191   /** ENUM (is an enum type) */
192   ENUM,
193
194   /** NOT_ENUM (not an enum type) */
195   NOT_ENUM,
196
197   /** ENUM_CONSTANT (is an enum constant field) */
198   ENUM_CONSTANT,
199
200   /** NOT_ENUM_CONSTANT (not an enum constant field) */
201   NOT_ENUM_CONSTANT,
202
203   /** HAS_PARAMS (has parameters) */
204   HAS_PARAMS,
205
206   /** HAS_NO_PARAMS (has no parameters) */
207   HAS_NO_PARAMS,
208
209   /** LOCAL (is a local class) */
210   LOCAL,
211
212   /** NOT_LOCAL (not a local class) */
213   NOT_LOCAL,
214
215   /** MEMBER (is a member class) */
216   MEMBER,
217
218   /** NOT_MEMBER (not a member class) */
219   NOT_MEMBER,
220
221   /** NON_STATIC_MEMBER (is a non-static member class) */
222   NON_STATIC_MEMBER,
223
224   /** NOT_NON_STATIC_MEMBER (not a non-static member class) */
225   NOT_NON_STATIC_MEMBER,
226
227   /** PRIMITIVE (is a primitive type) */
228   PRIMITIVE,
229
230   /** NOT_PRIMITIVE (not a primitive type) */
231   NOT_PRIMITIVE,
232
233   /** RECORD (is a record type) */
234   RECORD,
235
236   /** NOT_RECORD (not a record type) */
237   NOT_RECORD,
238
239   /** SEALED (is a sealed class) */
240   SEALED,
241
242   /** NOT_SEALED (not a sealed class) */
243   NOT_SEALED,
244
245   /** SYNTHETIC (is compiler-generated) */
246   SYNTHETIC,
247
248   /** NOT_SYNTHETIC (not compiler-generated) */
249   NOT_SYNTHETIC,
250
251   /** VARARGS (has variable arity) */
252   VARARGS,
253
254   /** NOT_VARARGS (does not have variable arity) */
255   NOT_VARARGS
256}