From 79b3a422df49a5d8a2ab37665a79e3223e81cf66 Mon Sep 17 00:00:00 2001 From: phfsut2ie Date: Mon, 28 Apr 2025 18:33:05 +0800 Subject: [PATCH] ADD file via upload --- ColumnInfo.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ColumnInfo.java diff --git a/ColumnInfo.java b/ColumnInfo.java new file mode 100644 index 0000000..5fec176 --- /dev/null +++ b/ColumnInfo.java @@ -0,0 +1,27 @@ +// 定义该文件所在的包路径,将该 Java 类组织到 com.annotation 这个包空间下,方便项目的模块化管理和避免类名冲突 +package com.annotation; + +// 导入 Java 语言中用于表示注解可应用的目标元素类型的类,通过该类可以指定注解能作用于类、方法、字段等不同的程序元素 +import java.lang.annotation.ElementType; + +// 导入用于指定注解保留策略的注解,借助它可以控制注解在不同阶段的可见性 +import java.lang.annotation.Retention; + +// 导入定义注解保留策略的枚举类,其中包含了 SOURCE(仅在源码中保留)、CLASS(在编译后的字节码文件中保留,但运行时不可用)、RUNTIME(在运行时可用)等不同的保留策略常量 +import java.lang.annotation.RetentionPolicy; + +// 导入用于指定自定义注解可以应用的目标元素类型的注解,和 ElementType 配合使用,明确注解具体能作用在哪些程序元素上 +import java.lang.annotation.Target; + +// 指定该注解可以应用于字段(类的成员变量)上 +@Target(ElementType.FIELD) +// 指定该注解在运行时保留,可以通过反射读取 +@Retention(RetentionPolicy.RUNTIME) +// 定义一个名为ColumnInfo的注解 +public @interface ColumnInfo { + // 定义comment属性,表示字段的注释/描述 + String comment(); + + // 定义type属性,表示字段的类型 + String type(); +} \ No newline at end of file