类 AnnotationAttributes

    • 构造器详细资料

      • AnnotationAttributes

        public AnnotationAttributes()
        创建一个新的空 AnnotationAttributes 实例。
      • AnnotationAttributes

        public AnnotationAttributes​(int initialCapacity)
        创建一个新的空 AnnotationAttributes 实例,该实例具有给定的初始容量以优化性能。
        参数:
        initialCapacity - 基础地图的初始大小
      • AnnotationAttributes

        public AnnotationAttributes​(@NotNull
                                    @NotNull Class<? extends Annotation> annotationType)
        为指定的 annotationType 创建一个新的空 AnnotationAttributes 实例。
    • 方法详细资料

      • annotationType

        @Nullable
        public @Nullable Class<? extends Annotation> annotationType()
        获取此 AnnotationAttributes 表示的注解类型。
        返回:
        注解类型,如果未知,则为 null
      • getString

        public String getString​(@NotNull
                                @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为字符串
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getStringArray

        public String[] getStringArray​(@NotNull
                                       @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为字符串数组
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getBoolean

        public boolean getBoolean​(@NotNull
                                  @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为布尔值
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getNumber

        public <N extends Number> N getNumber​(@NotNull
                                              @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为数字
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getEnum

        public <E extends Enum<?>> E getEnum​(@NotNull
                                             @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为枚举
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getClass

        public <T> Class<? extends T> getClass​(@NotNull
                                               @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为类
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getClassArray

        public Class<?>[] getClassArray​(@NotNull
                                        @NotNull String attributeName)
        获取存储在指定 attributeName 下的值作为类数组
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getAnnotation

        public <A extends Annotation> A getAnnotation​(@NotNull
                                                      @NotNull String attributeName,
                                                      @NotNull
                                                      @NotNull Class<A> annotationType)
        获取存储在指定 attributeName 下的类型 annotationType 的注释。
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getAnnotationArray

        public <A extends Annotation> A[] getAnnotationArray​(@NotNull
                                                             @NotNull String attributeName,
                                                             @NotNull
                                                             @NotNull Class<A> annotationType)
        获取存储在指定 attributeName 下的 注释类型 的数组
        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型
      • getRequiredAttribute

        public <T> T getRequiredAttribute​(@NotNull
                                          @NotNull String attributeName,
                                          @NotNull
                                          @NotNull Class<T> expectedType)
        获取存储在指定 attributeName 下的值,确保该值为 预期类型

        如果 expectType 是一个数组,并且存储在指定 attributeName 下的值是预期数组类型的组件类型的单个元素, 则单个元素将在返回之前包装在适当类型的单元素数组中。

        抛出:
        IllegalArgumentException - 如果属性不存在或不属于预期类型