Class Annotations.Handle

java.lang.Object
org.spongepowered.asm.util.Annotations.Handle
All Implemented Interfaces:
IAnnotationHandle
Enclosing class:
Annotations

public static class Annotations.Handle extends Object implements IAnnotationHandle
Wrapper for AnnotationNode to support access via common interface
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Get whether the annotation inside the handle actually exists, if the contained element is null, returns false.
    Get an annotation value as an annotation handle
    Retrieve an annotation key as a list of annotation handles
    boolean
    getBoolean(String key, boolean defaultValue)
    Get the primitive boolean value with the specified key or return null if not present or not set
    Get the annotation descriptor
    <T> List<T>
    Retrieve the annotation value as a list with values of the specified type.
    <T> List<T>
    Retrieve the annotation value with the specified key as a list with values of the specified type.
    org.objectweb.asm.tree.AnnotationNode
     
    List<org.objectweb.asm.Type>
    Retrieve an annotation key as a list of Types.
    org.objectweb.asm.Type
    Get an annotation value as an ASM Type.
    <T> T
    Get the annotation value or return null if not present or not set
    <T> T
    Get the annotation value with the specified key or return null if not present or not set
    <T> T
    getValue(String key, T defaultValue)
    Get a value with the specified key from this annotation, return the specified default value if the key is not set or is not present
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • exists

      public boolean exists()
      Description copied from interface: IAnnotationHandle
      Get whether the annotation inside the handle actually exists, if the contained element is null, returns false.
      Specified by:
      exists in interface IAnnotationHandle
      Returns:
      true if the annotation exists
    • getNode

      public org.objectweb.asm.tree.AnnotationNode getNode()
    • getDesc

      public String getDesc()
      Description copied from interface: IAnnotationHandle
      Get the annotation descriptor
      Specified by:
      getDesc in interface IAnnotationHandle
    • getAnnotationList

      public List<IAnnotationHandle> getAnnotationList(String key)
      Description copied from interface: IAnnotationHandle
      Retrieve an annotation key as a list of annotation handles
      Specified by:
      getAnnotationList in interface IAnnotationHandle
      Parameters:
      key - key to fetch
      Returns:
      list of annotations
    • getTypeValue

      public org.objectweb.asm.Type getTypeValue(String key)
      Description copied from interface: IAnnotationHandle
      Get an annotation value as an ASM Type. This is special-cased because the different APIs return class literals in different ways. Under ASM we will receieve Type instances, but at compile time we will get TypeMirrors instead. This overload is provided so that subclasses have to marshal everything into Type for consistency.
      Specified by:
      getTypeValue in interface IAnnotationHandle
      Parameters:
      key - key to fetch
      Returns:
      value
    • getTypeList

      public List<org.objectweb.asm.Type> getTypeList(String key)
      Description copied from interface: IAnnotationHandle
      Retrieve an annotation key as a list of Types. This is special-cased because the different APIs return class literals in different ways. Under ASM we will receieve Type instances, but at compile time we will get TypeMirrors instead. This overload is provided so that subclasses have to marshal everything into Type for consistency.
      Specified by:
      getTypeList in interface IAnnotationHandle
      Parameters:
      key - key to fetch
      Returns:
      list of types
    • getAnnotation

      public IAnnotationHandle getAnnotation(String key)
      Description copied from interface: IAnnotationHandle
      Get an annotation value as an annotation handle
      Specified by:
      getAnnotation in interface IAnnotationHandle
      Parameters:
      key - key to search for in the value map
      Returns:
      value or null if not set
    • getValue

      public <T> T getValue(String key, T defaultValue)
      Description copied from interface: IAnnotationHandle
      Get a value with the specified key from this annotation, return the specified default value if the key is not set or is not present
      Specified by:
      getValue in interface IAnnotationHandle
      Type Parameters:
      T - duck type
      Parameters:
      key - key
      defaultValue - value to return if the key is not set or not present
      Returns:
      value or default if not set
    • getValue

      public <T> T getValue()
      Description copied from interface: IAnnotationHandle
      Get the annotation value or return null if not present or not set
      Specified by:
      getValue in interface IAnnotationHandle
      Type Parameters:
      T - duck type
      Returns:
      value or null if not present or not set
    • getValue

      public <T> T getValue(String key)
      Description copied from interface: IAnnotationHandle
      Get the annotation value with the specified key or return null if not present or not set
      Specified by:
      getValue in interface IAnnotationHandle
      Type Parameters:
      T - duck type
      Parameters:
      key - key to fetch
      Returns:
      value or null if not present or not set
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Description copied from interface: IAnnotationHandle
      Get the primitive boolean value with the specified key or return null if not present or not set
      Specified by:
      getBoolean in interface IAnnotationHandle
      Parameters:
      key - key to fetch
      defaultValue - default value to return if value is not present
      Returns:
      value or default if not present or not set
    • getList

      public <T> List<T> getList()
      Description copied from interface: IAnnotationHandle
      Retrieve the annotation value as a list with values of the specified type. Returns an empty list if the value is not present or not set.
      Specified by:
      getList in interface IAnnotationHandle
      Type Parameters:
      T - list element duck type
      Returns:
      list of values
    • getList

      public <T> List<T> getList(String key)
      Description copied from interface: IAnnotationHandle
      Retrieve the annotation value with the specified key as a list with values of the specified type. Returns an empty list if the value is not present or not set.
      Specified by:
      getList in interface IAnnotationHandle
      Type Parameters:
      T - list element duck type
      Parameters:
      key - key to fetch
      Returns:
      list of values
    • toString

      public String toString()
      Overrides:
      toString in class Object