• java--annotation(注解)


    从下面的例子说起

    * @since 1.5
     * @jls 9.6.4.1 @Target
     * @jls 9.7.4 Where Annotations May Appear
     */
    @Documented
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.ANNOTATION_TYPE)
    public @interface Target {
        /**
         * Returns an array of the kinds of elements an annotation type
         * can be applied to.
         * @return an array of the kinds of elements an annotation type
         * can be applied to
         */
        ElementType[] value();
    }

    1.@Target(ElementType.FIELD)指定程序元注释所用的地方

    public enum ElementType {
        /** Class, interface (including annotation type), or enum declaration */
        TYPE,
    
        /** Field declaration (includes enum constants) */
        FIELD,
    
        /** Method declaration */
        METHOD,
    
        /** Formal parameter declaration */
        PARAMETER,
    
        /** Constructor declaration */
        CONSTRUCTOR,
    
        /** Local variable declaration */
        LOCAL_VARIABLE,
    
        /** Annotation type declaration */
        ANNOTATION_TYPE,
    
        /** Package declaration */
        PACKAGE,
    
        /**
         * Type parameter declaration
         *
         * @since 1.8
         */
        TYPE_PARAMETER,
    
        /**
         * Use of a type
         *
         * @since 1.8
         */
        TYPE_USE
    }

    2.@Retention(RetentionPolicy.RUNTIME)

    public enum RetentionPolicy {
        /**
         * Annotations are to be discarded by the compiler.
         */
        SOURCE,
    
        /**
         * Annotations are to be recorded in the class file by the compiler
         * but need not be retained by the VM at run time.  This is the default
         * behavior.
         */
        CLASS,
    
        /**
         * Annotations are to be recorded in the class file by the compiler and
         * retained by the VM at run time, so they may be read reflectively.
         *
         * @see java.lang.reflect.AnnotatedElement
         */
        RUNTIME
    }
  • 相关阅读:
    arthas-常用命令
    k8s-容器技术-Mount Namespace
    k8s-statefulset介绍
    k8s-yaml配置文件
    k8s-控制器模式
    k8s-pod使用
    k8s-pod简介(半原创)
    k8s-安装我们第一个集群
    k8s-安装
    Corn表达式详解(转)
  • 原文地址:https://www.cnblogs.com/b-dong/p/6343054.html
Copyright © 2020-2023  润新知