Enum Class ElementFlag

java.lang.Object
java.lang.Enum<ElementFlag>
org.apache.juneau.commons.reflect.ElementFlag
All Implemented Interfaces:
Serializable, Comparable<ElementFlag>, Constable

public enum ElementFlag extends Enum<ElementFlag>
Enumeration of possible modifiers and attributes that can be present on classes, methods, fields, and constructors.

This enum provides a comprehensive set of flags for identifying Java language modifiers (public, private, static, etc.) and other attributes (synthetic, deprecated, etc.) that can be present on program elements. Each modifier has both a positive flag (e.g., PUBLIC) and a negated flag (e.g., NOT_PUBLIC) for convenient filtering.

Features:
  • Java modifiers - all standard Java modifiers (public, private, protected, static, final, etc.)
  • Negated flags - each modifier has a corresponding NOT_* flag for filtering
  • Non-modifier attributes - flags for synthetic, deprecated, bridge methods, etc.
  • Type attributes - flags for identifying classes, interfaces, enums, records, annotations
Use Cases:
  • Filtering classes, methods, fields by modifiers
  • Identifying special attributes (synthetic, deprecated, bridge methods)
  • Type checking (enum, record, annotation, interface)
  • Building frameworks that need to analyze program element characteristics
Usage:

// Check if a class is public ClassInfo ci = ClassInfo.of(MyClass.class); boolean isPublic = ci.hasFlag(ElementFlag.PUBLIC); // Filter methods by modifier List<MethodInfo> staticMethods = ci.getMethods() .stream() .filter(m -> m.hasFlag(ElementFlag.STATIC)) .toList(); // Check for deprecated methods boolean isDeprecated = method.hasFlag(ElementFlag.DEPRECATED);

Modifier Flags:

Standard Java modifiers: PUBLIC, PRIVATE, PROTECTED, STATIC, FINAL, SYNCHRONIZED, VOLATILE, TRANSIENT, NATIVE, ABSTRACT. Each has a corresponding NOT_* flag.

Attribute Flags:

Non-modifier attributes: ANNOTATION, ANONYMOUS, ARRAY, BRIDGE, CLASS, CONSTRUCTOR, DEFAULT, DEPRECATED, ENUM, ENUM_CONSTANT, HAS_PARAMS, LOCAL, MEMBER, NON_STATIC_MEMBER, PRIMITIVE, RECORD, SEALED, SYNTHETIC, VARARGS.

See Also: