Skip to content

Commit ba77e79

Browse files
committed
Added documentation
1 parent a537d89 commit ba77e79

File tree

4 files changed

+89
-5
lines changed

4 files changed

+89
-5
lines changed

src/main/java/me/despical/commandframework/annotations/Confirmation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
TimeUnit timeUnit() default TimeUnit.SECONDS;
5151

5252
/**
53-
* If option is true, console will be affected by
53+
* If option is {@code true}, console will be affected by
5454
* confirmations; otherwise, it will override the
5555
* confirmation period to use the command again.
5656
*

src/main/java/me/despical/commandframework/annotations/Flag.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,53 @@
77
import java.lang.annotation.Target;
88

99
/**
10+
* Annotation to specify flags for command arguments.
11+
* This annotation can be used multiple times on the same method.
12+
*
13+
* <p>The {@code value()} method holds the list of flags, and the
14+
* {@code prefix()} method defines the default prefix for the flags,
15+
* which is {@code --} by default.</p>
16+
*
17+
* <p>The {@link FlagContainer} is a container annotation that allows
18+
* the {@link Flag} annotation to be repeatable on methods.</p>
19+
*
1020
* @author Despical
11-
* <p>
12-
* Created at 20.09.2024
21+
* <p>Created at 20.09.2024</p>
1322
*/
1423
@Target(ElementType.METHOD)
1524
@Retention(RetentionPolicy.RUNTIME)
1625
@Repeatable(Flag.FlagContainer.class)
1726
public @interface Flag {
1827

28+
/**
29+
* Specifies the list of flag values.
30+
*
31+
* @return an array of flag values
32+
*/
1933
String[] value();
2034

35+
/**
36+
* Specifies the prefix for the flags. Default is "--".
37+
*
38+
* @return the flag prefix
39+
*/
2140
String prefix() default "--";
2241

42+
/**
43+
* Container annotation for holding multiple {@link Flag} annotations
44+
* on the same method.
45+
*
46+
* <p>Used internally by the {@link Repeatable} annotation.</p>
47+
*/
2348
@Target(ElementType.METHOD)
2449
@Retention(RetentionPolicy.RUNTIME)
2550
@interface FlagContainer {
2651

52+
/**
53+
* Holds an array of {@link Flag} annotations.
54+
*
55+
* @return an array of {@link Flag} annotations
56+
*/
2757
Flag[] value();
2858
}
2959
}

src/main/java/me/despical/commandframework/annotations/Option.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,81 @@
77
import java.lang.annotation.Target;
88

99
/**
10+
* Annotation to define options for command arguments.
11+
* This annotation can be used multiple times on the same method.
12+
*
13+
* <p>The {@code value()} method represents the key of the option,
14+
* and the {@code prefix()} method defines the default prefix for options,
15+
* which is {@code --} by default.</p>
16+
*
17+
* <p>Additional separators can be customized using the {@code valueSeparator()}
18+
* and {@code keySeparator()} methods. By default, the value separator is
19+
* a comma ({@code ,}), and the key separator is an equals sign ({@code =}).
20+
* The {@code allowSeparating()} method controls whether separating values
21+
* is allowed, with the default set to {@code true}.</p>
22+
*
23+
* <p>The {@link OptionContainer} is a container annotation that allows
24+
* the {@link Option} annotation to be repeatable on methods.</p>
25+
*
1026
* @author Despical
11-
* <p>
12-
* Created at 20.09.2024
27+
* <p>Created at 20.09.2024</p>
1328
*/
1429
@Target(ElementType.METHOD)
1530
@Retention(RetentionPolicy.RUNTIME)
1631
@Repeatable(Option.OptionContainer.class)
1732
public @interface Option {
1833

34+
/**
35+
* Specifies the key of the option.
36+
*
37+
* @return the option key
38+
*/
1939
String value();
2040

41+
/**
42+
* Specifies the prefix for the options. Default is "--".
43+
*
44+
* @return the option prefix
45+
*/
2146
String prefix() default "--";
2247

48+
/**
49+
* Specifies the separator used between values. Default is a comma ",".
50+
*
51+
* @return the value separator
52+
*/
2353
String valueSeparator() default ",";
2454

55+
/**
56+
* Specifies the separator between key and value. Default is "=".
57+
*
58+
* @return the key-value separator
59+
*/
2560
String keySeparator() default "=";
2661

62+
/**
63+
* Determines whether separating multiple values is allowed.
64+
* Default is {@code true}.
65+
*
66+
* @return {@code true} if separating is allowed, {@code false} otherwise
67+
*/
2768
boolean allowSeparating() default true;
2869

70+
/**
71+
* Container annotation for holding multiple {@link Option} annotations
72+
* on the same method.
73+
*
74+
* <p>Used internally by the {@link Repeatable} annotation.</p>
75+
*/
2976
@Target(ElementType.METHOD)
3077
@Retention(RetentionPolicy.RUNTIME)
3178
@interface OptionContainer {
3279

80+
/**
81+
* Holds an array of {@link Option} annotations.
82+
*
83+
* @return an array of {@link Option} annotations
84+
*/
3385
Option[] value();
3486
}
3587
}

src/main/java/me/despical/commandframework/parser/OptionParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import me.despical.commandframework.annotations.Flag;
44
import me.despical.commandframework.annotations.Option;
5+
import org.jetbrains.annotations.ApiStatus;
56

67
import java.lang.reflect.Method;
78
import java.util.*;
@@ -12,6 +13,7 @@
1213
* <p>
1314
* Created at 20.09.2024
1415
*/
16+
@ApiStatus.Internal
1517
public class OptionParser {
1618

1719
private final Flag[] flags;

0 commit comments

Comments
 (0)