summaryrefslogtreecommitdiff
path: root/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GroupMatchedCommands.java
blob: de89e00c8d9b8900220309881d1b9f713b8d4ec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package io.dico.dicore.command.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation to define sub-groups of the group registered reflectively from all methods in a class.
 * <p>
 * Commands are selected for grouping by matching their method's names to a regular expression.
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface GroupMatchedCommands {

    @Retention(RetentionPolicy.RUNTIME)
    @interface GroupEntry {

        /**
         * Regular expression to match method names for this group
         * Must be non-empty
         *
         * @return the regular expression
         */
        String regex();

        /**
         * The name or main key of the sub-group or address
         * Must be non-empty
         *
         * @return the group name
         */
        String group();

        /**
         * The aliases for the sub-group
         *
         * @return the group aliases
         */
        String[] groupAliases() default {};

        /**
         * Generated (predefined) commands for the sub-group
         */
        String[] generatedCommands() default {};

        /**
         * @see Desc
         */
        String[] description() default {};

        /**
         * @see Desc
         */
        String shortDescription() default "";
    }

    /**
     * The defined groups.
     * If a method name matches the regex of multiple groups,
     * groups are prioritized by the order in which they appear in this array.
     *
     * @return the defined groups
     */
    GroupEntry[] value();

}