Skip to content

Commit c937cf5

Browse files
committed
Improve JavaDoc for annotations
1 parent 002d852 commit c937cf5

34 files changed

+345
-11
lines changed

src/main/java/org/apache/ibatis/annotations/Arg.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/**
2828
* The annotation that specify a mapping definition for the constructor argument.
2929
*
30+
* @see ConstructorArgs
3031
* @author Clinton Begin
3132
*/
3233
@Documented

src/main/java/org/apache/ibatis/annotations/AutomapConstructor.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,6 +24,26 @@
2424
/**
2525
* The marker annotation that indicate a constructor for automatic mapping.
2626
*
27+
* <p><br>
28+
* <b>How to use:</b>
29+
* <pre>
30+
* public class User {
31+
*
32+
* private int id;
33+
* private String name;
34+
*
35+
* public User(int id) {
36+
* this.id = id;
37+
* }
38+
*
39+
* &#064;AutomapConstructor
40+
* public User(int id, String name) {
41+
* this.id = id;
42+
* this.name = name;
43+
* }
44+
* // ...
45+
* }
46+
* </pre>
2747
* @author Tim Chen
2848
* @since 3.4.3
2949
*/

src/main/java/org/apache/ibatis/annotations/CacheNamespace.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
/**
2929
* The annotation that specify to use cache on namespace(e.g. mapper interface).
3030
*
31+
* <p><br>
32+
* <b>How to use:</b>
33+
* <pre>
34+
* &#064;acheNamespace(implementation = CustomCache.class, properties = {
35+
* &#064;Property(name = "host", value = "${mybatis.cache.host}"),
36+
* &#064;Property(name = "port", value = "${mybatis.cache.port}"),
37+
* &#064;Property(name = "name", value = "usersCache")
38+
* })
39+
* public interface UserMapper {
40+
* // ...
41+
* }
42+
* </pre>
3143
* @author Clinton Begin
3244
* @author Kazuki Shimizu
3345
*/

src/main/java/org/apache/ibatis/annotations/CacheNamespaceRef.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@
2323

2424
/**
2525
* The annotation that reference a cache.
26-
* <p>
27-
* If you use this annotation, should be specified either {@link #value()} or {@link #name()} attribute.
28-
* </p>
26+
*
27+
* <p>If you use this annotation, should be specified either {@link #value()} or {@link #name()} attribute.
28+
*
29+
* <p><br>
30+
* <b>How to use:</b>
31+
* <pre>
32+
* &#064;CacheNamespaceRef(UserMapper.class)
33+
* public interface AdminUserMapper {
34+
* // ...
35+
* }
36+
* </pre>
2937
* @author Clinton Begin
3038
* @author Kazuki Shimizu
3139
*/
@@ -35,12 +43,16 @@
3543
public @interface CacheNamespaceRef {
3644

3745
/**
38-
* A namespace type to reference a cache (the namespace name become a FQCN of specified type).
46+
* Returns the namespace type to reference a cache (the namespace name become a FQCN of specified type).
47+
*
48+
* @return the namespace type to reference a cache
3949
*/
4050
Class<?> value() default void.class;
4151

4252
/**
43-
* A namespace name to reference a cache.
53+
* Returns the namespace name to reference a cache.
54+
*
55+
* @return the namespace name
4456
* @since 3.4.2
4557
*/
4658
String name() default "";

src/main/java/org/apache/ibatis/annotations/Case.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
/**
2424
* The annotation that conditional mapping definition for {@link TypeDiscriminator}.
2525
*
26+
* @see TypeDiscriminator
27+
* @see Result
28+
* @see Arg
29+
* @see Results
30+
* @see ConstructorArgs
2631
* @author Clinton Begin
2732
*/
2833
@Documented

src/main/java/org/apache/ibatis/annotations/ConstructorArgs.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
/**
2525
* The annotation that be grouping mapping definitions for constructor.
2626
*
27+
* <p><br>
28+
* <b>How to use:</b>
29+
* <pre>
30+
* public interface UserMapper {
31+
* &#064;ConstructorArgs({
32+
* &#064;Arg(column = "id", javaType = int.class, id = true),
33+
* &#064;Arg(column = "name", javaType = String.class),
34+
* &#064;Arg(javaType = UserEmail.class, select = "selectUserEmailById", column = "id")
35+
* })
36+
* &#064;Select("SELECT id, name FROM users WHERE id = #{id}")
37+
* User selectById(int id);
38+
* }
39+
* </pre>
2740
* @author Clinton Begin
2841
*/
2942
@Documented

src/main/java/org/apache/ibatis/annotations/Delete.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
/**
2525
* The annotation that specify an SQL for deleting record(s).
2626
*
27+
* <p><br>
28+
* <b>How to use:</b>
29+
* <pre>
30+
* public interface UserMapper {
31+
* &#064;Delete("DELETE FROM users WHERE id = #{id}")
32+
* boolean deleteById(int id);
33+
* }
34+
* </pre>
2735
* @author Clinton Begin
2836
*/
2937
@Documented

src/main/java/org/apache/ibatis/annotations/DeleteProvider.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
/**
2525
* The annotation that specify a method that provide an SQL for deleting record(s).
2626
*
27+
* <p><br>
28+
* <b>How to use:</b>
29+
* <pre>
30+
* public interface UserMapper {
31+
*
32+
* &#064;DeleteProvider(type = SqlProvider.class, method = "deleteById")
33+
* boolean deleteById(int id);
34+
*
35+
* public static class SqlProvider {
36+
* public static String deleteById() {
37+
* return "DELETE FROM users WHERE id = #{id}";
38+
* }
39+
* }
40+
*
41+
* }
42+
* </pre>
2743
* @author Clinton Begin
2844
*/
2945
@Documented

src/main/java/org/apache/ibatis/annotations/Flush.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2016 the original author or authors.
2+
* Copyright 2009-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,6 +24,14 @@
2424
/**
2525
* The maker annotation that invoke a flush statements via Mapper interface.
2626
*
27+
* <p><br>
28+
* <b>How to use:</b>
29+
* <pre>
30+
* public interface UserMapper {
31+
* &#064;Flush
32+
* List&lt;BatchResult&gt; flush();
33+
* }
34+
* </pre>
2735
* @since 3.3.0
2836
* @author Kazuki Shimizu
2937
*/

src/main/java/org/apache/ibatis/annotations/Insert.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
/**
2525
* The annotation that specify an SQL for inserting record(s).
2626
*
27+
* <p><br>
28+
* <b>How to use:</b>
29+
* <pre>
30+
* public interface UserMapper {
31+
* &#064;Insert("INSERT INTO users (id, name) VALUES(#{id}, #{name})")
32+
* void insert(User user);
33+
* }
34+
* </pre>
2735
* @author Clinton Begin
2836
*/
2937
@Documented

0 commit comments

Comments
 (0)