Skip to content

[doc] add comment for java's annotation lib file. #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 86 additions & 7 deletions language/java/lib/Annotation.gdl
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
/**
* @brief Describe an annotated relation.
* @brief Relationship between annotation and annotated element
* @corresponds Java AST: Connection between annotation node and target
* @example
* <pre>{@code
* @interface Entity {}
*
* @Entity
* class User {
* @Id
* private Long id;
* }
* }</pre>
*/
schema AnnotatedRelation extends AnnotatedRelationDO {

}

impl AnnotatedRelation {
@data_constraint
@inline
Expand Down Expand Up @@ -38,9 +50,16 @@ impl AnnotatedRelation {
}
}
}


/**
* @brief Base class for annotation data storage
* @corresponds Java AST: Database structure for annotation nodes
*/
schema AnnotationDo {
@primary id: int
}

impl AnnotationDo {
@data_constraint
@inline
Expand Down Expand Up @@ -168,8 +187,18 @@ impl AnnotationDo {
}
}
}


/**
* @brief An access annotation.
* @brief Concrete annotation instance
* @corresponds Java AST: Annotation application node
* @example
* <pre>{@code
* @GetMapping("/users")
* public List<User> getUsers() {
* // method implementation
* }
* }</pre>
*/
schema Annotation extends AnnotationDo {

Expand Down Expand Up @@ -370,8 +399,16 @@ impl AnnotationAccessArgumentDO {
}
}
}


/**
* @brief An argument that applies to an annotation.
* @brief Concrete annotation argument value
* @corresponds Java AST: Argument value specification
* @example
* <pre>{@code
* @Retry(maxAttempts = 3, delay = 1000L)
* void process() {}
* }</pre>
*/
schema AnnotationAccessArgument extends AnnotationAccessArgumentDO {

Expand Down Expand Up @@ -515,8 +552,18 @@ impl AnnotationAccessArgument {
}
}
}


/**
* @brief Represents an array used as a value of an annotation element. For example: @Endorsers({"Children", "Unscrupulous dentists"})
* @brief Annotation array initializer
* @example
* <pre>{@code
* @Authors({
* @Author(name = "Alice"),
* @Author(name = "Bob")
* })
* class Book {}
* }</pre>
*/
schema AnnotationArrayInitializer extends AnnotationArrayInitializerDO {

Expand Down Expand Up @@ -579,8 +626,17 @@ impl AnnotationArrayInitializer {
}
}
}


/**
* @brief An annotation that applies to a declaration.
* @brief Annotation type declaration
* @example
* <pre>{@code
* @interface Scheduled {
* String cron();
* boolean enableRetry() default false;
* }
* }</pre>
*/
schema AnnotationDeclaration extends AnnotationDeclarationDO {

Expand Down Expand Up @@ -622,8 +678,19 @@ impl AnnotationDeclaration {
}
}
}


/**
* @brief A parameter that applied to a annotation declaration.
* @brief Parameter definition in annotation type declarations
* @corresponds Java AST: AnnotationTypeElementDeclaration node
* @example
* <pre>{@code
* @interface TestConfig {
* // Represents two parameters
* int timeout() default 30; // AnnotationDeclarationParameter 1
* String[] cases(); // AnnotationDeclarationParameter 2
* }
* }</pre>
*/
schema AnnotationDeclarationParameter extends AnnotationDeclarationParameterDO {

Expand Down Expand Up @@ -688,8 +755,20 @@ impl AnnotationDeclarationParameter {
}
}
}

/**
* @brief Default value for an annotation parameter, if any.
* @brief Default value specification for annotation parameters
* @corresponds Java AST: AnnotationTypeElementDefaultValue node
* @example
* <pre>{@code
* @interface TimeoutConfig {
* // Parameter with default value
* int duration() default 30; // ← This default clause
*
* // Parameter without default
* String unit();
* }
* }</pre>
*/
schema AnnotationDeclarationParameterDefaultValue extends AnnotationDeclarationParameterDefaultValueDO {

Expand Down