Class ElementInfo

java.lang.Object
org.apache.juneau.commons.reflect.ElementInfo
Direct Known Subclasses:
AccessibleInfo, ClassInfo, ParameterInfo

public abstract class ElementInfo extends Object
Abstract base class for all reflection wrapper objects providing common modifier checking functionality.

This class provides the foundation for all reflection info wrappers (classes, methods, fields, constructors, etc.) by providing common functionality for checking Java language modifiers and element flags. Subclasses extend this to provide specific functionality for their element type.

Features:
  • Modifier checking - check for public, private, protected, static, final, etc.
  • Flag checking - check for element flags using ElementFlag
  • Combined flag checking - check for multiple flags at once
  • Extensible - subclasses can add element-specific flag checks
Use Cases:
  • Checking modifiers on reflection elements
  • Filtering elements by flags
  • Building frameworks that need to analyze element characteristics
Usage:

// Check modifiers ElementInfo ei = ...; boolean isPublic = ei.isPublic(); boolean isStatic = ei.isStatic(); // Check flags boolean hasFlag = ei.hasFlag(ElementFlag.PUBLIC); boolean hasAllFlags = ei.hasAllFlags(ElementFlag.PUBLIC, ElementFlag.STATIC);

See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ElementInfo(int modifiers)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <A extends Annotation>
    AnnotationInfo<A>
    ai(Annotatable on, A value)
     
    int
    Returns the Java language modifiers for this element.
    boolean
    Returns true if the specified flag is applicable to this element.
    boolean
    Returns true if this element is abstract.
    boolean
    isAll(ElementFlag... flags)
    Returns true if all specified flags are applicable to this element.
    boolean
    isAny(ElementFlag... flags)
    Returns true if any of the specified flags are applicable to this element.
    boolean
    Returns true if this element is final.
    boolean
    Returns true if this element is an interface.
    boolean
    Returns true if this element is native.
    boolean
    Returns true if this element is not abstract.
    boolean
    Returns true if this element is not final.
    boolean
    Returns true if this element is not an interface.
    boolean
    Returns true if this element is not native.
    boolean
    Returns true if this element is not private.
    boolean
    Returns true if this element is not protected.
    boolean
    Returns true if this element is not public.
    boolean
    Returns true if this element is not static.
    boolean
    Returns true if this element is not synchronized.
    boolean
    Returns true if this element is not transient.
    boolean
    Returns true if this element is not volatile.
    boolean
    Returns true if this element is private.
    boolean
    Returns true if this element is protected.
    boolean
    Returns true if this element is public.
    boolean
    Returns true if this element is static.
    boolean
    Returns true if this element is synchronized.
    boolean
    Returns true if this element is transient.
    boolean
    Returns true if this element is volatile.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ElementInfo

      protected ElementInfo(int modifiers)
      Constructor.
      Parameters:
      modifiers - The Java modifiers for this element.
  • Method Details

    • getModifiers

      public int getModifiers()
      Returns the Java language modifiers for this element.
      Returns:
      The Java language modifiers for this element.
    • is

      public boolean is(ElementFlag flag)
      Returns true if the specified flag is applicable to this element.

      Subclasses should override this method and call super.is(flag) to handle common modifier flags, then handle their own specific flags.

      Parameters:
      flag - The flag to test for.
      Returns:
      true if the specified flag is applicable to this element.
    • isAbstract

      public boolean isAbstract()
      Returns true if this element is abstract.
      Returns:
      true if this element is abstract.
    • isAll

      public boolean isAll(ElementFlag... flags)
      Returns true if all specified flags are applicable to this element.

      Subclasses should override this method and call super.isAll(flags) to handle common modifier flags, then handle their own specific flags.

      Parameters:
      flags - The flags to test for.
      Returns:
      true if all specified flags are applicable to this element.
    • isAny

      public boolean isAny(ElementFlag... flags)
      Returns true if any of the specified flags are applicable to this element.

      Subclasses should override this method and call super.isAny(flags) to handle common modifier flags, then handle their own specific flags.

      Parameters:
      flags - The flags to test for.
      Returns:
      true if any of the specified flags are applicable to this element.
    • isFinal

      public boolean isFinal()
      Returns true if this element is final.
      Returns:
      true if this element is final.
    • isInterface

      public boolean isInterface()
      Returns true if this element is an interface.
      Returns:
      true if this element is an interface.
    • isNative

      public boolean isNative()
      Returns true if this element is native.
      Returns:
      true if this element is native.
    • isNotAbstract

      public boolean isNotAbstract()
      Returns true if this element is not abstract.
      Returns:
      true if this element is not abstract.
    • isNotFinal

      public boolean isNotFinal()
      Returns true if this element is not final.
      Returns:
      true if this element is not final.
    • isNotInterface

      public boolean isNotInterface()
      Returns true if this element is not an interface.
      Returns:
      true if this element is not an interface.
    • isNotNative

      public boolean isNotNative()
      Returns true if this element is not native.
      Returns:
      true if this element is not native.
    • isNotPrivate

      public boolean isNotPrivate()
      Returns true if this element is not private.
      Returns:
      true if this element is not private.
    • isNotProtected

      public boolean isNotProtected()
      Returns true if this element is not protected.
      Returns:
      true if this element is not protected.
    • isNotPublic

      public boolean isNotPublic()
      Returns true if this element is not public.
      Returns:
      true if this element is not public.
    • isNotStatic

      public boolean isNotStatic()
      Returns true if this element is not static.
      Returns:
      true if this element is not static.
    • isNotSynchronized

      public boolean isNotSynchronized()
      Returns true if this element is not synchronized.
      Returns:
      true if this element is not synchronized.
    • isNotTransient

      public boolean isNotTransient()
      Returns true if this element is not transient.
      Returns:
      true if this element is not transient.
    • isNotVolatile

      public boolean isNotVolatile()
      Returns true if this element is not volatile.
      Returns:
      true if this element is not volatile.
    • isPrivate

      public boolean isPrivate()
      Returns true if this element is private.
      Returns:
      true if this element is private.
    • isProtected

      public boolean isProtected()
      Returns true if this element is protected.
      Returns:
      true if this element is protected.
    • isPublic

      public boolean isPublic()
      Returns true if this element is public.
      Returns:
      true if this element is public.
    • isStatic

      public boolean isStatic()
      Returns true if this element is static.
      Returns:
      true if this element is static.
    • isSynchronized

      public boolean isSynchronized()
      Returns true if this element is synchronized.
      Returns:
      true if this element is synchronized.
    • isTransient

      public boolean isTransient()
      Returns true if this element is transient.
      Returns:
      true if this element is transient.
    • isVolatile

      public boolean isVolatile()
      Returns true if this element is volatile.
      Returns:
      true if this element is volatile.
    • ai

      protected <A extends Annotation> AnnotationInfo<A> ai(Annotatable on, A value)