Class CAnnotation

  • All Implemented Interfaces:
    Serializable, xyz.cofe.collection.ImTree<ByteCode>, xyz.cofe.collection.ImTreeWalk<ByteCode>, AnnotationDef, GetAnnotationByteCodes, ByteCode, ClazzWriter, ClsByteCode

    public class CAnnotation
    extends Object
    implements ClsByteCode, AnnotationDef, GetAnnotationByteCodes, ClazzWriter
    Аннотация прикрепленная к классу

    Есть такие классы

    public @interface Desc {
      String value();
    }
     
    @Desc("sample User2")
    public class User2 {
        public User2(){}
        public User2(String name1){
            this.name = name1;
        }
    
        @Desc("name of user")
        private String name;
    
        @Desc("name of user")
        public String getName(){ return name; }
        public void setName( @Required @MaxLength(100) @MinLength(1) String name ){ this.name = name; }
    
        private List emails;
        @Desc("emails of user")
        public List getEmails(){ return emails; }
        public void setEmails( List emails ){ this.emails = emails; }
    }
    
    В результате будет
     <CBegin
        version="55"
        access="33"
        name="xyz/cofe/bc/xml/clss/User2"
        superName="java/lang/Object" interface="false">
    
        <CSource order="0" source="User2.java"/>
         <CAnnotation
               order="1"
               visible="true"
               descriptor="Lxyz/cofe/bc/xml/clss/Desc;">
    
             <APairString name="value">
                 <APairStringValue>sample User2</APairStringValue>
             </APairString>
             <AEnd/>
         </CAnnotation>
     
    See Also:
    Serialized Form
    • Field Detail

      • descriptor

        protected String descriptor
        Имя типа аннотации
      • visible

        protected boolean visible
        true если аннотация видна в runtime
      • annotationByteCodes

        protected List<AnnotationByteCode> annotationByteCodes
        вложенные параметры аннотации
    • Constructor Detail

      • CAnnotation

        public CAnnotation()
        Конструктор по умолчанию
      • CAnnotation

        public CAnnotation​(String descriptor,
                           boolean visible)
        Конструктор
        Parameters:
        descriptor - имя типа аннотации
        visible - true если аннотация видна в runtime
      • CAnnotation

        public CAnnotation​(CAnnotation sample)
        Конструктор копирования
        Parameters:
        sample - образец
    • Method Detail

      • configure

        public CAnnotation configure​(Consumer<CAnnotation> conf)
        Конфигурация экземпляра
        Parameters:
        conf - конфигурация
        Returns:
        SELF ссылка
      • getDescriptor

        public String getDescriptor()
        Возвращает имя типа аннотации
        Returns:
        имя типа аннотации
      • setDescriptor

        public void setDescriptor​(String descriptor)
        Указывает имя типа аннотации
        Parameters:
        descriptor - имя типа аннотации
      • isVisible

        public boolean isVisible()
        Возвращает видна ли аннотация в runtime
        Returns:
        true если аннотация видна в runtime
      • setVisible

        public void setVisible​(boolean visible)
        Указывает видна ли аннотация в runtime
        Parameters:
        visible - true если аннотация видна в runtime
      • setAnnotationByteCodes

        public void setAnnotationByteCodes​(List<AnnotationByteCode> byteCodes)
        Возвращает вложенные параметры аннотации
        Parameters:
        byteCodes - вложенные параметры аннотации
      • nodes

        public xyz.cofe.iter.Eterable<ByteCode> nodes()
        Возвращает дочерние узлы
        Specified by:
        nodes in interface ByteCode
        Specified by:
        nodes in interface xyz.cofe.collection.ImTree<ByteCode>
        Returns:
        дочерние узлы
      • write

        public void write​(org.objectweb.asm.ClassWriter v)
        Specified by:
        write in interface ClazzWriter